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 during login #918

Open
davidgwking opened this issue May 24, 2017 · 4 comments
Open

NullPointerException during login #918

davidgwking opened this issue May 24, 2017 · 4 comments
Labels

Comments

@davidgwking
Copy link

davidgwking commented May 24, 2017

Description:

I am receiving a NullPointerException when attempting to login. Any help would be appreciated.

Steps to reproduce:

This exception occurs when invoking login on an instance of PokemonGo. I had this very same issue a couple of weeks ago, but it appeared transient at the time.

I am using the GoogleAutoCredentialProvider.

@Bean("cred")
public CredentialProvider makeCredentialProvider(@Value("${google.username}") String u, @Value("${google.password}") String p)
		throws InvalidCredentialsException, LoginFailedException {
	return new GoogleAutoCredentialProvider(new OkHttpClient(), u, p);
}

@Bean("hash")
public HashProvider makeHashProvider(@Value("${hashkey}") String k) {
	return new PokeHashProvider(PokeHashKey.from(k), false);
}

@Autowired
@Bean("client")
public PokemonGo makePokemonGoClient(CredentialProvider cred, HashProvider hash) throws RequestFailedException {
	PokemonGo client = new PokemonGo(new OkHttpClient());
	client.login(cred, hash);
    return client;
}

Expected behavior:
No exception.

Actual behavior:
NullPointerException

Stacktrace (If it's a crash):

Caused by: java.lang.NullPointerException: null
	at com.pokegoapi.api.pokemon.Evolution.<init>(Evolution.java:46) ~[PokeGOAPI-library-all-0.4.1.jar:na]
	at com.pokegoapi.api.pokemon.Evolutions.addEvolution(Evolutions.java:58) ~[PokeGOAPI-library-all-0.4.1.jar:na]
	at com.pokegoapi.api.pokemon.Evolutions.addEvolution(Evolutions.java:61) ~[PokeGOAPI-library-all-0.4.1.jar:na]
	at com.pokegoapi.api.pokemon.Evolutions.addEvolution(Evolutions.java:61) ~[PokeGOAPI-library-all-0.4.1.jar:na]
	at com.pokegoapi.api.pokemon.Evolutions.<init>(Evolutions.java:45) ~[PokeGOAPI-library-all-0.4.1.jar:na]
	at com.pokegoapi.api.settings.templates.ItemTemplates.reloadTemplates(ItemTemplates.java:166) ~[PokeGOAPI-library-all-0.4.1.jar:na]
	at com.pokegoapi.api.settings.templates.ItemTemplates.<init>(ItemTemplates.java:75) ~[PokeGOAPI-library-all-0.4.1.jar:na]
	at com.pokegoapi.api.PokemonGo.login(PokemonGo.java:218) ~[PokeGOAPI-library-all-0.4.1.jar:na]
	at com.davidgwking.PgathenaApplication.makePokemonGoClient(PgathenaApplication.java:40) [main/:na]
	at com.davidgwking.PgathenaApplication$$EnhancerBySpringCGLIB$$a15d3327.CGLIB$makePokemonGoClient$2(<generated>) ~[main/:na]
	at com.davidgwking.PgathenaApplication$$EnhancerBySpringCGLIB$$a15d3327$$FastClassBySpringCGLIB$$d9506fc7.invoke(<generated>) ~[main/:na]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at com.davidgwking.PgathenaApplication$$EnhancerBySpringCGLIB$$a15d3327.makePokemonGoClient(<generated>) ~[main/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_91]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_91]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_91]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]

Version:
Development branch HEAD

@Gegy
Copy link
Collaborator

Gegy commented May 24, 2017

Somehow the PokemonSettings for a pokemon don't exist when populating the evolution branches. Try reset the item_templates file in your temp directory.

@davidgwking
Copy link
Author

Thank you; cleaning up those temp dirs temporarily fixes this issue.

@Gegy
Copy link
Collaborator

Gegy commented May 24, 2017

Seems this problem is related to the update of the item templates

@Gegy Gegy added the bug label May 24, 2017
@just-Addict
Copy link

just-Addict commented May 25, 2017

This exact same issue occurs for some users of BPGM on first start of the program and so far in every case where a user experienced this, the item_templates file appeared to be an incorrect (?) size. After deleting this file and having it redownloaded, the correct size appears to be 220Kb (224.900 bytes) at which point the error no longer occurred.

If the filesize is something that can be predicted or if there is another way to verify the file is valid then the solution would be to implement some form of validity check and retry if that fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants