mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
StringBuilder in a class field may cause memory leaks, it's not GCed, so it's a better way to store all errors just in string field
This commit is contained in:
parent
eb58391fe2
commit
3600d03e2c
1 changed files with 5 additions and 2 deletions
|
@ -40,7 +40,8 @@ import org.apache.log4j.Logger;
|
||||||
public abstract class DeckImporter {
|
public abstract class DeckImporter {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(DeckImporter.class);
|
private static final Logger logger = Logger.getLogger(DeckImporter.class);
|
||||||
protected StringBuilder sbMessage = new StringBuilder();
|
|
||||||
|
protected String errors;
|
||||||
protected int lineCount;
|
protected int lineCount;
|
||||||
|
|
||||||
public DeckCardLists importDeck(String file) {
|
public DeckCardLists importDeck(String file) {
|
||||||
|
@ -51,6 +52,7 @@ public abstract class DeckImporter {
|
||||||
return deckList;
|
return deckList;
|
||||||
}
|
}
|
||||||
lineCount = 0;
|
lineCount = 0;
|
||||||
|
StringBuilder sbMessage = new StringBuilder();
|
||||||
sbMessage.setLength(0);
|
sbMessage.setLength(0);
|
||||||
try {
|
try {
|
||||||
try (Scanner scanner = new Scanner(f)) {
|
try (Scanner scanner = new Scanner(f)) {
|
||||||
|
@ -68,11 +70,12 @@ public abstract class DeckImporter {
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.fatal(null, ex);
|
logger.fatal(null, ex);
|
||||||
}
|
}
|
||||||
|
errors = sbMessage.toString();
|
||||||
return deckList;
|
return deckList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getErrors(){
|
public String getErrors(){
|
||||||
return sbMessage.toString();
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void readLine(String line, DeckCardLists deckList);
|
protected abstract void readLine(String line, DeckCardLists deckList);
|
||||||
|
|
Loading…
Reference in a new issue