Skip to content

Commit

Permalink
Make inner classes static when feasible
Browse files Browse the repository at this point in the history
A static nested class does not keep an implicit reference to its
enclosing instance.

This prevents a common cause of memory leaks and uses less memory per
instance of the class.

Closes gh-28433
  • Loading branch information
missingdays authored and sbrannen committed May 10, 2022
1 parent e26d883 commit 941b92c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void handleRequest(HttpServerExchange exchange) {
}


private class HandlerResultSubscriber implements Subscriber<Void> {
private static class HandlerResultSubscriber implements Subscriber<Void> {

private final HttpServerExchange exchange;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected VersionStrategy getStrategyForPath(String requestPath) {
}


private class FileNameVersionedResource extends AbstractResource implements HttpResource {
private static class FileNameVersionedResource extends AbstractResource implements HttpResource {

private final Resource original;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Mono<Void> upgrade(ServerWebExchange exchange, WebSocketHandler handler,
}


private class DefaultCallback implements WebSocketConnectionCallback {
private static class DefaultCallback implements WebSocketConnectionCallback {

private final HandshakeInfo handshakeInfo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ protected VersionStrategy getStrategyForPath(String requestPath) {
}


private class FileNameVersionedResource extends AbstractResource implements HttpResource {
private static class FileNameVersionedResource extends AbstractResource implements HttpResource {

private final Resource original;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected SockJsFrameFormat getFrameFormat(ServerHttpRequest request) {
}


private class XhrStreamingSockJsSession extends StreamingSockJsSession {
private static class XhrStreamingSockJsSession extends StreamingSockJsSession {

public XhrStreamingSockJsSession(String sessionId, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
Expand Down

0 comments on commit 941b92c

Please sign in to comment.