8148417: Memory leak in javadoc DocFileFactory

Reviewed-by: ksrini
This commit is contained in:
Jonathan Gibbons 2016-01-27 20:47:21 -08:00
parent 111381cb6b
commit f1852fe3f1
2 changed files with 6 additions and 9 deletions

View File

@ -311,6 +311,8 @@ public abstract class Configuration {
public final Map<ProgramElementDoc, ProgramElementDoc> classPropertiesMap = new HashMap<>();
public final Map<ProgramElementDoc, GetterSetter> getterSetterMap = new HashMap<>();
public DocFileFactory docFileFactory;
/**
* Constructor. Constructs the message retriever with resource file.
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,9 +25,6 @@
package com.sun.tools.doclets.internal.toolkit.util;
import java.util.Map;
import java.util.WeakHashMap;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileManager.Location;
import javax.tools.StandardJavaFileManager;
@ -45,15 +42,13 @@ import com.sun.tools.doclets.internal.toolkit.Configuration;
*
* @since 1.8
*/
abstract class DocFileFactory {
private static final Map<Configuration, DocFileFactory> factories = new WeakHashMap<>();
public abstract class DocFileFactory {
/**
* Get the appropriate factory, based on the file manager given in the
* configuration.
*/
static synchronized DocFileFactory getFactory(Configuration configuration) {
DocFileFactory f = factories.get(configuration);
DocFileFactory f = configuration.docFileFactory;
if (f == null) {
JavaFileManager fm = configuration.getFileManager();
if (fm instanceof StandardJavaFileManager) {
@ -61,7 +56,7 @@ abstract class DocFileFactory {
} else {
throw new IllegalStateException();
}
factories.put(configuration, f);
configuration.docFileFactory = f;
}
return f;
}