mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +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 {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(DeckImporter.class);
|
||||
protected StringBuilder sbMessage = new StringBuilder();
|
||||
|
||||
protected String errors;
|
||||
protected int lineCount;
|
||||
|
||||
public DeckCardLists importDeck(String file) {
|
||||
|
@ -51,6 +52,7 @@ public abstract class DeckImporter {
|
|||
return deckList;
|
||||
}
|
||||
lineCount = 0;
|
||||
StringBuilder sbMessage = new StringBuilder();
|
||||
sbMessage.setLength(0);
|
||||
try {
|
||||
try (Scanner scanner = new Scanner(f)) {
|
||||
|
@ -68,11 +70,12 @@ public abstract class DeckImporter {
|
|||
} catch (Exception ex) {
|
||||
logger.fatal(null, ex);
|
||||
}
|
||||
errors = sbMessage.toString();
|
||||
return deckList;
|
||||
}
|
||||
|
||||
public String getErrors(){
|
||||
return sbMessage.toString();
|
||||
return errors;
|
||||
}
|
||||
|
||||
protected abstract void readLine(String line, DeckCardLists deckList);
|
||||
|
|
Loading…
Reference in a new issue