Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in search bar #537

Closed
desb42 opened this issue Aug 10, 2019 · 3 comments
Closed

NullPointerException in search bar #537

desb42 opened this issue Aug 10, 2019 · 3 comments

Comments

@desb42
Copy link
Collaborator

desb42 commented Aug 10, 2019

Using xowa-http (buildt using xowa_get_and_make.sh)
This trace occurred when I was trying a search in the searchbar

localhost:8080|POST|{"cmd":"xowa.search.ui.suggest","data":{"wiki":"de.wikipedia.org","search":"ne","cbk":"receiveSuggestions"}}

exec json failed: json
failed to process request;
request=type: POST      url: /exec/json protocol: HTTP/1.1      host: localhost:8080    user_agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36 accept: */*     accept_encoding: gzip, deflate, br      dnt: false      x_requested_with: <<NULL>>      cookie: <<NULL>>        referer: http://localhost:8080/de.wikipedia.org/        content_length: 348     content_type: multipart/form-data       content_type_boundary: ------WebKitFormBoundary4bBZoCyAQMwOaZHL connection: keep-alive  pragma: <<NULL>>        cache_control: <<NULL>>
          msg: {"cmd":"xowa.search.ui.suggest","data":{"wiki":"de.wikipedia.org","search":"ne","cbk":"receiveSuggestions"}}
          app_mode: http_server

err_msg=[err 0] <java.lang.NullPointerException> null
[err 1] <bridge.cmds> exec json failed: json={"cmd":"xowa.search.ui.suggest","data":{"wiki":"de.wikipedia.org","search":"ne","cbk":"receiveSuggestions"}}

[trace]:
  gplx.xowa.addons.wikis.searchs.Srch_search_addon.Get(Unknown Source)
  gplx.xowa.addons.wikis.searchs.gui.htmlbars.Srch_htmlbar_mgr.Search(Unknown Source)
  gplx.xowa.addons.wikis.searchs.gui.htmlbars.Bridge_cmd_itm__srch_suggest.Exec(Unknown Source)
  gplx.xowa.htmls.bridges.Bridge_cmd_mgr.Exec(Unknown Source)
  gplx.xowa.apps.servers.http.Http_server_wkr.Process_post(Unknown Source)
  gplx.xowa.apps.servers.http.Http_server_wkr.Run(Unknown Source)
  gplx.xowa.apps.servers.http.Http_server_wkr.Invk(Unknown Source)
  gplx.Gfo_invk_.Invk_by_msg(Unknown Source)
  gplx.core.threads.Thread_adp.run(Unknown Source)
  java.lang.Thread.run(Thread.java:748)

I have tracked this down to the fact that I am restarting xowa-http and immediately doing a search

The issue arises in Bridge_cmd_itm__srch_suggest.java, line 32

Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgri().Get_by_or_null(wiki_bry);

This is returning a null, in the immediate restart scenario

I believe this line should be

Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgri().Get_by_or_make_init_y(wiki_bry);

To add the wiki if necessary

@desb42
Copy link
Collaborator Author

desb42 commented Aug 10, 2019

not quite right

having applied the above fix

restarting and immediately placing kyl in the search bar (for any already displayed enwiki page)
I get the following results
imediat1

If I again restart, refresh the enwiki page and then place kyl in the searhbar, I get
imediat2

There seems to be some conditioning that is missing on an immediate search

@gnosygnu
Copy link
Owner

Thanks. I was able to reproduce both.

The problem occurs because :

  • There's some hacky HTTP_Server code that "re-inits" everything by calling: Gxw_html_server.Init_gui_for_server(app, null);
  • This hacky code is responsible for loading "auto-wildcard" from the cfg.
    • The 1st screenshot only literally has "kyl" results
    • The 2nd screenshot has "kyl*" results
  • It only gets called during page_load
  • However, pasting something directly into the search_suggest box calls POST code and never actually loads a page

I'll figure out a better place for the hacky init code in the morning.

@gnosygnu gnosygnu added this to In progress in A <div> in D Aug 11, 2019
gnosygnu added a commit that referenced this issue Aug 11, 2019
gnosygnu added a commit that referenced this issue Aug 11, 2019
@gnosygnu
Copy link
Owner

Fixed both issues with the commit above. Also, removed the trailing new line which showed up in the console output.

Thanks for the original code pointer!

@gnosygnu gnosygnu moved this from In progress to Done in A <div> in D Aug 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
A <div> in D
  
Done
Development

No branches or pull requests

2 participants