= Corrected edge case of null string parsing
This commit is contained in:
@@ -58,8 +58,6 @@ You successfully voted for=
|
||||
|
||||
[CommandShutdown]
|
||||
Stops kitty. `-s` or `safe` as an argument attempts to sync off the database before shutdown.=
|
||||
Forced shutdown, database synced before abandoning threads.=
|
||||
Forced immediate shutdown, threads abandoned without sync.=
|
||||
|
||||
[CommandBetBeans]
|
||||
That's not a valid bet!=
|
||||
|
||||
@@ -11,6 +11,8 @@ import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
|
||||
// NOTE(wisp): This is a sort of special command.
|
||||
public class CommandShutdown extends Command
|
||||
@@ -41,13 +43,14 @@ public class CommandShutdown extends Command
|
||||
|
||||
if(isSafe)
|
||||
{
|
||||
DatabaseManager.instance.Upkeep(); // Force upkeep, this works so long as on main thread.
|
||||
res.CallImmediate(Localizer.Stub("Forced shutdown, database synced before abandoning threads."));
|
||||
// Force upkeep, this works so long as upkeep is on the main thread.
|
||||
DatabaseManager.instance.Upkeep();
|
||||
GlobalLog.Error(LogFilter.Command, "Forced shutdown, database synced before abandoning threads.");
|
||||
System.exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.CallImmediate(Localizer.Stub("Forced immediate shutdown, threads abandoned without sync."));
|
||||
GlobalLog.Error(LogFilter.Command, "Forced immediate shutdown, threads abandoned without sync.");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,17 +123,16 @@ public class Localizer
|
||||
try
|
||||
{
|
||||
String fileContents = ReadFileAsString(filename, Charset.defaultCharset());
|
||||
System.out.println("File contents: " + fileContents);
|
||||
|
||||
if(fileContents == null)
|
||||
{
|
||||
File file = new File(filename);
|
||||
file.createNewFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
stringStore = new SectionedKeyValueStore(fileContents);
|
||||
}
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
Error("IO exception during localization file read");
|
||||
|
||||
@@ -109,6 +109,9 @@ public class SectionedKeyValueStore
|
||||
// account of some characters having specific regex meanings.
|
||||
private void Parse(String input)
|
||||
{
|
||||
if(input == null)
|
||||
return;
|
||||
|
||||
String[] sections = input.split("\\" + SectionStart);
|
||||
|
||||
for(int sec = 0; sec < sections.length; ++sec)
|
||||
|
||||
Reference in New Issue
Block a user