Skip to content

Commit 8283411

Browse files
committed
Retire Interner added in commits f4355bf, bfbf5b4
Java 7 moved intern() out of permgen, so Interner is deprecated. Its use in Ctags(Reader) was buggy, since a new Interner instance was created per line, negating the value of the Interner. Also: - revise all HistoryParser subclasses to addFile() with intern() paths
1 parent cb98b70 commit 8283411

File tree

9 files changed

+29
-254
lines changed

9 files changed

+29
-254
lines changed

src/org/opensolaris/opengrok/analysis/CtagsReader.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.logging.Level;
2929
import java.util.logging.Logger;
3030
import org.opensolaris.opengrok.logger.LoggerFactory;
31-
import org.opensolaris.opengrok.util.Interner;
3231

3332
/**
3433
* Represents a reader of output from runs of ctags.
@@ -204,12 +203,10 @@ public void readLine(String tagLine) {
204203

205204
// Bug #809: Keep track of which symbols have already been
206205
// seen to prevent duplicating them in memory.
207-
final Interner<String> seenSymbols = new Interner<>();
208206

209207
final String type = classInher == null ? kind : kind + " in " +
210208
classInher;
211-
addTag(defs, seenSymbols, lnum, def, type, match, classInher,
212-
signature);
209+
addTag(defs, lnum, def, type, match, classInher, signature);
213210
if (signature != null) {
214211
// TODO if some languages use different character for separating
215212
// arguments, below needs to be adjusted
@@ -250,9 +247,8 @@ public void readLine(String tagLine) {
250247
for (int ii = names.length - 1; ii >= 0; ii--) {
251248
name = names[ii];
252249
if (name.length() > 0) {
253-
addTag(defs, seenSymbols, lnum, name, "argument",
254-
def.trim() + signature.trim(), null,
255-
signature);
250+
addTag(defs, lnum, name, "argument", def.trim() +
251+
signature.trim(), null, signature);
256252
break;
257253
}
258254
}
@@ -266,9 +262,8 @@ public void readLine(String tagLine) {
266262
/**
267263
* Adds a tag to a {@code Definitions} instance.
268264
*/
269-
private void addTag(Definitions defs, Interner<String> seenSymbols,
270-
String lnum, String symbol, String type, String text, String namespace,
271-
String signature) {
265+
private void addTag(Definitions defs, String lnum, String symbol,
266+
String type, String text, String namespace, String signature) {
272267
// The strings are frequently repeated (a symbol can be used in
273268
// multiple definitions, multiple definitions can have the same type,
274269
// one line can contain multiple definitions). Intern them to minimize
@@ -280,9 +275,8 @@ private void addTag(Definitions defs, Interner<String> seenSymbols,
280275
LOGGER.log(Level.WARNING, "CTags line number parsing problem(but" +
281276
" I will continue with line # 0) for symbol {0}", symbol);
282277
}
283-
defs.addTag(lineno, seenSymbols.intern(symbol.trim()),
284-
seenSymbols.intern(type.trim()), seenSymbols.intern(text.trim()),
285-
namespace == null ? null : seenSymbols.intern(namespace.trim()),
286-
signature);
278+
defs.addTag(lineno, symbol.trim().intern(), type.trim().intern(),
279+
text.trim().intern(), namespace == null ? null :
280+
namespace.trim().intern(), signature);
287281
}
288282
}

src/org/opensolaris/opengrok/history/BazaarHistoryParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
22+
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
2223
*/
2324
package org.opensolaris.opengrok.history;
2425

@@ -168,7 +169,7 @@ public void processStream(InputStream input) throws IOException {
168169

169170
File f = new File(myDir, s);
170171
String name = env.getPathRelativeToSourceRoot(f);
171-
entry.addFile(name);
172+
entry.addFile(name.intern());
172173
}
173174
break;
174175
default:

src/org/opensolaris/opengrok/history/BitKeeperHistoryParser.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
* CDDL HEADER END
1818
*/
1919

20+
/*
21+
* Copyright (c) 2017, James Service <[email protected]>.
22+
* Portions Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
23+
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
24+
*/
25+
2026
package org.opensolaris.opengrok.history;
2127

2228
import java.io.BufferedReader;
@@ -107,7 +113,7 @@ public void processStream(InputStream input) throws IOException {
107113
if (fields[0].equals("ChangeSet")) {
108114
continue;
109115
}
110-
newEntry.addFile(fields[0]);
116+
newEntry.addFile(fields[0].intern());
111117
newEntry.setRevision(fields[1]);
112118
newEntry.setDate(dateFormat.parse(fields[2]));
113119
newEntry.setAuthor(fields[3]);

src/org/opensolaris/opengrok/history/GitHistoryParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
22+
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
2223
*/
2324
package org.opensolaris.opengrok.history;
2425

@@ -128,7 +129,8 @@ private void process(BufferedReader in) throws IOException {
128129
if (entry != null) {
129130
try {
130131
File f = new File(myDir, s);
131-
entry.addFile(env.getPathRelativeToSourceRoot(f));
132+
String path = env.getPathRelativeToSourceRoot(f);
133+
entry.addFile(path.intern());
132134
} catch (FileNotFoundException e) { //NOPMD
133135
// If the file is not located under the source root,
134136
// ignore it (bug #11664).

src/org/opensolaris/opengrok/history/MercurialHistoryParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
22+
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
2223
*/
2324
package org.opensolaris.opengrok.history;
2425

@@ -140,7 +141,8 @@ public void processStream(InputStream input) throws IOException {
140141
if (strings[ii].length() > 0) {
141142
File f = new File(mydir, strings[ii]);
142143
try {
143-
entry.addFile(env.getPathRelativeToSourceRoot(f));
144+
String path = env.getPathRelativeToSourceRoot(f);
145+
entry.addFile(path.intern());
144146
} catch (FileNotFoundException e) { // NOPMD
145147
// If the file is not located under the source root,
146148
// ignore it (bug #11664).

src/org/opensolaris/opengrok/history/MonotoneHistoryParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
22+
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
2223
*/
2324
package org.opensolaris.opengrok.history;
2425

@@ -164,7 +165,9 @@ public void processStream(InputStream input) throws IOException {
164165
for (String f : files) {
165166
File file = new File(mydir, f);
166167
try {
167-
entry.addFile(env.getPathRelativeToSourceRoot(file));
168+
String path = env.getPathRelativeToSourceRoot(
169+
file);
170+
entry.addFile(path.intern());
168171
} catch (FileNotFoundException e) { // NOPMD
169172
// If the file is not located under the source root, ignore it
170173
}

src/org/opensolaris/opengrok/history/SubversionHistoryParser.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
22+
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
2223
*/
2324
package org.opensolaris.opengrok.history;
2425

@@ -38,7 +39,6 @@
3839
import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
3940
import org.opensolaris.opengrok.logger.LoggerFactory;
4041
import org.opensolaris.opengrok.util.Executor;
41-
import org.opensolaris.opengrok.util.Interner;
4242
import org.xml.sax.Attributes;
4343
import org.xml.sax.SAXException;
4444
import org.xml.sax.ext.DefaultHandler2;
@@ -64,7 +64,6 @@ private static class Handler extends DefaultHandler2 {
6464
final DateFormat format;
6565
HistoryEntry entry;
6666
StringBuilder sb;
67-
private final Interner<String> stringInterner = new Interner<String>();
6867

6968
Handler(String home, String prefix, int length, DateFormat df) {
7069
this.home = home;
@@ -105,11 +104,7 @@ public void endElement(String uri, String localName, String qname) throws SAXExc
105104
String path = file.getAbsolutePath().substring(length);
106105
// The same file names may be repeated in many commits,
107106
// so intern them to reduce the memory footprint.
108-
// Bug #15956: Don't use String.intern(), since that may
109-
// exhaust the permgen space. Instead, use our own
110-
// interner that allocates space on the heap.
111-
path = stringInterner.intern(path);
112-
entry.addFile(path);
107+
entry.addFile(path.intern());
113108
} else {
114109
LOGGER.log(Level.FINER, "Skipping file outside repository: " + s);
115110
}

src/org/opensolaris/opengrok/util/Interner.java

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)