exception - Why is my Java app getting killed? -


i wrong line causing problem, error changes everytime change if() statement:

try {      while(true) {         string lru = hashoperation();         system.out.println("in worker thread, should valid json: " + lru);         if (jsonvalidator.isstringvalidjson(lru) && !lru.isempty()) {               hashmap<string,string> messagemap = jsongenerator.readjson(lru); 

so assume problem if() statement. if write this:

if (jsonvalidator.isstringvalidjson(lru)) { 

then app starts , exception:

in worker thread, should valid json:  exception in worker thread in main::main: no content map object due end of input 

but if write this:

if (jsonvalidator.isstringvalidjson(lru) && !lru.isempty()) { 

then app starts up, instantly dies:

/usr/bin/java -cp /home/jenkins/run-nlp/ssam.jar com.sofar.ssam.main starting nlp app 2015/08/30 21:42:28  loading classifier dependencies/english.all.7class.distsim.crf.ser.gz ... killed 

the basic idea here app starts , spins background threads poll endlessly on redis, looking input (the input comes app, publishes data channel on redis).

when see "killed" assume exception went uncaught, have whole thread::run() wrapped in try/catch ends with:

} catch (exception e) {     system.out.println("exception in worker thread in main::main: " + e.getmessage()); } 

you can see exception message if this:

if (jsonvalidator.isstringvalidjson(lru)) { 

although possible error elsewhere, , think odd empty string valid json, thought screen out possibility with:

if (jsonvalidator.isstringvalidjson(lru) && !lru.isempty()) { 

why 1 change cause app killed?

update:

i refactored app this:

static void processmessage(ssambrain ssambrain, jedis jedis, hashmap<string, string> responsemap, jsongenerator jsongenerator, jsonvalidator jsonvalidator, string lru) { try {         if (!lru.isempty()) {             hashmap<string,string> messagemap = jsongenerator.readjson(lru);             transformer transformer = new transformer(); 

again, line causes problem seems be:

        if (!lru.isempty()) { 

if don't have if() statement, code gets:

java.io.eofexception: no content map object due end of input  

on next line, since empty string not valid json.

but when add this:

        if (!lru.isempty()) { 

then app dies on startup.

maybe autoboxing problem? or absence of it? assume now:

lru = "";

i assume can call methods on it, maybe not? , why wouldn't exception?

it's possible problem elsewhere, if() statement seems main thing causes problem surface.

update

update

the app survives few minutes, other times dies after few seconds. guess need ask:

1.) when java app says "killed" in terminal, mean exception went uncaught?

2.) might cause such variable behavior?

how works if operator:

if (condition_1 && condition_2){  dosomething(); } 
  1. checks condition_1 - if true:
  2. checks condition_2 - if true:
  3. runs dosometring().

if condition_1 false or throws exception, condition_2 never checks.

  1. please, show exception stacktrace.
  2. change:

    if (jsonvalidator.isstringvalidjson(lru) && !lru.isempty()) 

to:

    if (!lru.isempty() && jsonvalidator.isstringvalidjson(lru))  

so, first check if lru empty , if not - run validation.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -