Skip to content

Commit

Permalink
OWB-1389 Remove destroyed instance from memory
Browse files Browse the repository at this point in the history
  • Loading branch information
BuZZ-dEE committed Sep 7, 2021
1 parent d830ebe commit aa54458
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public TomcatInstanceManager(ClassLoader loader, InstanceManager processor)
@Override
public void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException
{
Object injectorInstance = objects.get(instance);
Object injectorInstance = this.objects.get(instance);
if (injectorInstance != null)
{
try
Expand All @@ -60,10 +60,15 @@ public void destroyInstance(Object instance) throws IllegalAccessException, Invo
}
catch (Exception e)
{
log.error("Erros is occured while destroying the OpenWebBeans injector instance", e);
log.error("Error is occured while destroying the OpenWebBeans injector instance", e);
}
}
this.processor.destroyInstance(instance);
this.objects.remove(instance);
if (log.isDebugEnabled())
{
log.debug("Number of 'objects' map entries after destroying instance: " + this.objects.size());
}
}

@Override
Expand Down Expand Up @@ -122,7 +127,11 @@ private void inject(Object object)
Object injectorInstance = TomcatUtil.inject(object, loader);
if (injectorInstance != null)
{
objects.put(object, injectorInstance);
this.objects.put(object, injectorInstance);
}
if (log.isDebugEnabled())
{
log.debug("Number of 'objects' map entries after injecting instance: " + this.objects.size());
}
}
catch (Exception e)
Expand Down

0 comments on commit aa54458

Please sign in to comment.