io.ebeaninternal.server.core.InternString Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
package io.ebeaninternal.server.core;
import java.util.HashMap;
/**
* Used to reduce memory consumption of strings used in deployment processing.
*
* Using this for now instead of String.intern() to avoid any unexpected
* increase in PermGen space.
*
*/
public final class InternString {
private static final HashMap map = new HashMap<>();
/**
* Return the shared instance of this string.
*/
public static String intern(String s) {
if (s == null) {
return null;
}
//noinspection SynchronizationOnStaticField
synchronized (map) {
String v = map.get(s);
if (v != null) {
return v;
} else {
map.put(s, s);
return s;
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy