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