From a16b81529f917451953043dcef060d5b2541566d Mon Sep 17 00:00:00 2001 From: Carsten Hammer Date: Sun, 1 Nov 2020 11:56:40 +0100 Subject: Bug: org.eclipse.equinox.http.servlet.internal.context.ProxyContext$ContextAttributes is serializable but also an inner class of a non-serializable class This Serializable class is an inner class of a non-serializable class. Thus, attempts to serialize it will also attempt to associate instance of the outer class with which it is associated, leading to a runtime error. If possible, making the inner class a static inner class should solve the problem. Making the outer class serializable might also work, but that would mean serializing an instance of the inner class would always also serialize the instance of the outer class, which it often not what you really want. Rank: Troubling (14), confidence: High Pattern: SE_BAD_FIELD_INNER_CLASS Type: Se, Category: BAD_PRACTICE (Bad practice) Change-Id: I06c93020982fd2a593189bb5650e2734410c0134 Signed-off-by: Carsten Hammer --- .../eclipse/equinox/http/servlet/internal/context/ProxyContext.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ProxyContext.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ProxyContext.java index c668225a6..4c66f40ae 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ProxyContext.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ProxyContext.java @@ -67,7 +67,7 @@ public class ProxyContext { ContextAttributes contextAttributes = attributesMap.get(controller); if (contextAttributes == null) { - contextAttributes = new ContextAttributes(controller); + contextAttributes = new ContextAttributes(controller, proxyContextTempDir); attributesMap.put(controller, contextAttributes); } @@ -122,13 +122,13 @@ public class ProxyContext { return directory.delete(); } - public class ContextAttributes + public static class ContextAttributes extends Dictionary implements Serializable { private static final long serialVersionUID = 1916670423277243587L; private final AtomicInteger referenceCount = new AtomicInteger(); - public ContextAttributes(ContextController controller) { + public ContextAttributes(ContextController controller, File proxyContextTempDir) { if (proxyContextTempDir != null) { File contextTempDir = new File( proxyContextTempDir, -- cgit v1.2.3