ldaranijo / google-voice-java

Automatically exported from code.google.com/p/google-voice-java
0 stars 1 forks source link

NullPointerException in get(url) method #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Many of my users are getting the following NullPointerException being thrown.  
I have yet to reproduce it on my Google Voice account:

java.lang.NullPointerException:
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.readln(HttpURLConnection.java:1178)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection$ChunkedInputStream.readChunkSize(HttpURLConnection.java:389)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection$ChunkedInputStream.<init>(HttpURLConnection.java:341)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getContentStream(HttpURLConnection.java:1074)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.doRequestInternal(HttpURLConnection.java:1656)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.doRequest(HttpURLConnection.java:1551)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:1273)
  at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnection.getResponseCode(HttpsURLConnection.java:116)
  at com.techventus.server.voice.Voice.get(Voice.java:1192)
  at com.techventus.server.voice.Voice.getGeneral(Voice.java:405)
  at com.techventus.server.voice.Voice.init(Voice.java:303)
  at com.techventus.server.voice.Voice.<init>(Voice.java:263)

Original issue reported on code.google.com by gurur...@gmail.com on 10 Jun 2010 at 4:35

GoogleCodeExporter commented 9 years ago
Forgot to add, this NullPointer exception happens during the constructor:

voice = new Voice(uName, pass,"My-GoogleVoice",false,Voice.GOOGLE);

Original comment by gurur...@gmail.com on 10 Jun 2010 at 4:37

GoogleCodeExporter commented 9 years ago
I've done a bit of investigating on this. It looks like Android's 
implementation of HttpURLConnection is based partially on Apache's Harmony 
project (which actually works on JDK 1.5, not v6). However, looking in their 
source did not reveal the correct line numbers, so this may required digging 
into the actual source for the Android system before this can be resolved. On 
our side it occurs when we call conn.getResponseCode(); in the get(urlString) 
method.

@gururise: Do you have the Android OS version for the users who are getting 
this exception?

Original comment by liquid...@gmail.com on 11 Jun 2010 at 3:22

GoogleCodeExporter commented 9 years ago
19 reports came from the Verizon Droid in the past 2 weeks (v2.0+ but most of 
them are probably running v2.1 by now), and two reports came from a Nexus One 
(v2.1 or v2.2)

So all the reports came from Android v2.0 or Higher.

Original comment by gurur...@gmail.com on 11 Jun 2010 at 3:49

GoogleCodeExporter commented 9 years ago
Any progress on this issue? Are the latest commits related to this?

Original comment by gurur...@gmail.com on 18 Jun 2010 at 3:45

GoogleCodeExporter commented 9 years ago
My android app has thrown an Apache Harmony error perhaps similar to your error 
on Froyo emulation mode.  It is a problem certainly to be solved.

Original comment by malone.j...@gmail.com on 18 Jun 2010 at 5:16

GoogleCodeExporter commented 9 years ago
The latest commits are not related to this issue.

Original comment by liquid...@gmail.com on 18 Jun 2010 at 12:51

GoogleCodeExporter commented 9 years ago
@gururise The latest change 
(http://code.google.com/p/google-voice-java/source/detail?r=118) may fix the 
problem for you. Are you able to replicate the problem yourself? I haven't had 
time to setup and Android 2.1 emulator to test the problem, but from what I'm 
reading, it may stem from timeouts on the connection, so I've added a forced 
connect each place in the code where we check the response code.

Original comment by liquid...@gmail.com on 24 Jun 2010 at 3:57

GoogleCodeExporter commented 9 years ago
@liquidhot: I myself haven't seen the problem, but my users see the problem. 
I'll go ahead and push out the changes and see if the problem goes away. I'll 
let you know in a few days.

Original comment by gurur...@gmail.com on 26 Jun 2010 at 4:58

GoogleCodeExporter commented 9 years ago
The error still exists:

java.lang.NullPointerException:
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.readln(HttpURLConnection.java:1178)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection$ChunkedInputStream.readChunkSize(HttpURLConnection.java:389)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection$ChunkedInputStream.<init>(HttpURLConnection.java:341)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getContentStream(HttpURLConnection.java:1074)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.doRequestInternal(HttpURLConnection.java:1656)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.doRequest(HttpURLConnection.java:1551)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:1273)
  at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnection.getResponseCode(HttpsURLConnection.java:116)
  at com.techventus.server.voice.Voice.get(Voice.java:1220)
  at com.techventus.server.voice.Voice.getGeneral(Voice.java:428)
  at com.techventus.server.voice.Voice.init(Voice.java:326)
  at com.techventus.server.voice.Voice.<init>(Voice.java:252)
  at com.realtynode.gvfree.gvdialer$3.run(gvdialer.java:247)

Original comment by gurur...@gmail.com on 7 Jul 2010 at 4:24

GoogleCodeExporter commented 9 years ago
I should clarify my above statement.  The error still exists as of r118.

Original comment by gurur...@gmail.com on 7 Jul 2010 at 4:26

GoogleCodeExporter commented 9 years ago
I can confirm that r119 still has this issue.

Original comment by gurur...@gmail.com on 14 Jul 2010 at 5:58

GoogleCodeExporter commented 9 years ago
I uploaded a new jar 1.7 which was compiled with Jave 5.  Please test if the 
Apache Harmony error still exists with this version.  This is a shot in the 
dark, but please test it.

Original comment by malone.j...@gmail.com on 6 Aug 2010 at 7:03

GoogleCodeExporter commented 9 years ago
I've always been using the source from SVN and compiling myself.  The last 
version of the source I used that exhibited this problem was r119.

I'll try using the jar 1.7 package instead and see if it makes the problem go 
away.

Original comment by gurur...@gmail.com on 6 Aug 2010 at 7:33

GoogleCodeExporter commented 9 years ago
Using the jar 1.7 package results in the same NullPointerException:

java.lang.NullPointerException:
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.readln(HttpURLConnection.java:1178)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection$ChunkedInputStream.readChunkSize(HttpURLConnection.java:389)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection$ChunkedInputStream.<init>(HttpURLConnection.java:341)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getContentStream(HttpURLConnection.java:1074)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.doRequestInternal(HttpURLConnection.java:1656)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.doRequest(HttpURLConnection.java:1551)
  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:1273)
  at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnection.getResponseCode(HttpsURLConnection.java:116)
  at com.techventus.server.voice.Voice.get(Voice.java:1227)
  at com.techventus.server.voice.Voice.getGeneral(Voice.java:428)
  at com.techventus.server.voice.Voice.init(Voice.java:326)
  at com.techventus.server.voice.Voice.<init>(Voice.java:252)
  at com.realtynode.gvfree.gvdialer$2.run(gvdialer.java:247)

Original comment by gurur...@gmail.com on 7 Aug 2010 at 7:52

GoogleCodeExporter commented 9 years ago
OK, I actually think I compiled it incorrectly.  Please disregard request for 
testing.  Will try again later.

Original comment by malone.j...@gmail.com on 8 Aug 2010 at 4:44

GoogleCodeExporter commented 9 years ago
My Users are having the same problems - null pointer exception on the first get 
- doesnt happen evertime, though.
Will try compiling the svn with java5.

Original comment by teisentr...@gmail.com on 17 Aug 2010 at 7:10

GoogleCodeExporter commented 9 years ago
@teisentr: Did you manage to compile with java5 and get things to work?

Original comment by gurur...@gmail.com on 18 Aug 2010 at 4:20

GoogleCodeExporter commented 9 years ago
It compiles fine, but i just rolled out an update yesterday, will let my users 
try in a couple days.

Original comment by teisentr...@gmail.com on 19 Aug 2010 at 8:22

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I checked in a piece of code which now checks if the input stream is null, and 
if so it throws an exception with the error code. Now its not a nullpointer but 
a real error. Here is what my first user report said:

08-22 21:23:34.721  2329  2462 E L_GVOICE_PLUGIN: https://www.google.com/voice/ 
: Moved Temporarily(302) : InputStream was null : exiting. 
08-22 21:23:34.721  2329  2329 D L_GVOICE_PLUGIN: Error 
(SETTINGS_AFTER_LOGIN):https://www.google.com/voice/ : Moved Temporarily(302) : 
InputStream was null : exiting.
08-22 21:23:34.721  2329  2329 W System.err: java.io.IOException: 
https://www.google.com/voice/ : Moved Temporarily(302) : InputStream was null : 
exiting.
08-22 21:23:34.721  2329  2329 W System.err: at 
com.techventus.server.voice.Voice.get(Voice.java:1238)
08-22 21:23:34.721  2329  2329 W System.err: at 
com.techventus.server.voice.Voice.getGeneral(Voice.java:428)
08-22 21:23:34.721  2329  2329 W System.err: at 
com.techventus.server.voice.Voice.init(Voice.java:326)
08-22 21:23:34.721  2329  2329 W System.err: at 
com.techventus.server.voice.Voice.<init>(Voice.java:252)
08-22 21:23:34.721  2329  2329 W System.err: at 
com.steelgirder.LocaleGoogleVoicePlugin.EditYourSettingActivity$1.call(EditYourS
ettingActivity.java:201)
08-22 21:23:34.721  2329  2329 W System.err: at 
com.steelgirder.LocaleGoogleVoicePlugin.EditYourSettingActivity$1.call(EditYourS
ettingActivity.java:1)
08-22 21:23:34.721  2329  2329 W System.err: at 
utils.LongRunningActionDispatcher$1.run(LongRunningActionDispatcher.java:74)
08-22 21:23:34.721  2329  2329 W System.err: at 
java.lang.Thread.run(Thread.java:1102)

I noticed that liquidhot changed the follow redirects - could it have something 
to do with that? http://code.google.com/p/google-voice-java/source/detail?r=119

Original comment by teisentr...@gmail.com on 23 Aug 2010 at 4:49

GoogleCodeExporter commented 9 years ago
Can everyone please test with your users if my last commit fixed the problem? 
http://code.google.com/p/google-voice-java/source/detail?r=123

Original comment by teisentr...@gmail.com on 24 Aug 2010 at 8:47

GoogleCodeExporter commented 9 years ago
I have not tested your code yet - one of my users recently reported a problem 
with Multiple Accounts. When he disabled multiple Accounts, the problem went 
away.  I was thinking of making this a separate Issue.  Tobias' latest commit 
may have solved it but I just want to get this out there 

I( 7810) https://www.google.com/accounts/ClientLogin - OK  (System.out)
D( 7810) GC_FOR_MALLOC freed 7309 objects / 380312 bytes in 91ms  (dalvikvm)
I( 7810) Default buffer size used in BufferedReader constructor. It would be 
better to be explicit if an 8k-char buffer is required.  (global)
I( 7810) Logged in to Google - Auth token received  (System.out)
D( 7810) Freeing OpenSSL session  (NativeCrypto)
I( 7810) https://www.google.com/voice/ - OK  (System.out)
I( 7810) Default buffer size used in BufferedReader constructor. It would be 
better to be explicit if an 8k-char buffer is required.  (global)
D( 7810) Freeing OpenSSL session  (NativeCrypto)
D( 7810) GC_FOR_MALLOC freed 7779 objects / 563704 bytes in 767ms  (dalvikvm)
D( 7810) Freeing OpenSSL session  (NativeCrypto)
D( 7810) GC_FOR_MALLOC freed 3075 objects / 369496 bytes in 33ms  (dalvikvm)
D( 7810) GC_FOR_MALLOC freed 38 objects / 72304 bytes in 33ms  (dalvikvm)
I( 7810) Grow heap (frag case) to 3.336MB for 94268-byte allocation  
(dalvikvm-heap)
D( 7810) GC_FOR_MALLOC freed 0 objects / 0 bytes in 44ms  (dalvikvm)
D( 7810) GC_FOR_MALLOC freed 37 objects / 65304 bytes in 30ms  (dalvikvm)
D( 7810) GC_FOR_MALLOC freed 27 objects / 96048 bytes in 28ms  (dalvikvm)
D( 7810) GC_FOR_MALLOC freed 6 objects / 141616 bytes in 28ms  (dalvikvm)
D( 7810) GC_FOR_MALLOC freed 3 objects / 72 bytes in 30ms  (dalvikvm)
I( 7810) Grow heap (frag case) to 3.569MB for 173858-byte allocation  
(dalvikvm-heap)
D( 7810) GC_FOR_MALLOC freed 0 objects / 0 bytes in 49ms  (dalvikvm)
D( 7810) GC_FOR_MALLOC freed 87 objects / 297896 bytes in 37ms  (dalvikvm)
D( 7810) GC_FOR_MALLOC freed 16 objects / 246008 bytes in 36ms  (dalvikvm)
I( 7810) Grow heap (frag case) to 3.634MB for 260782-byte allocation  
(dalvikvm-heap)
D( 7810) GC_FOR_MALLOC freed 0 objects / 0 bytes in 49ms  (dalvikvm)
D( 7810) GC_FOR_MALLOC freed 149 objects / 364272 bytes in 49ms  (dalvikvm)
I( 7810) Successfully Received rnr_se.  (System.out)
I( 7810) https://www.google.com/voice/inbox/recent/all/ - Moved Temporarily  
(System.out)
E( 7810) EXECUTION: UPDATE STATUS SET status = 'No Connexion' WHERE key = 
'google';  (TECHVENTUS)
W( 7810) java.lang.NullPointerException  (System.err)
W( 7810) at java.io.Reader.<init>(Reader.java:65)  (System.err)
W( 7810) at java.io.InputStreamReader.<init>(InputStreamReader.java:65)  
(System.err)
W( 7810) at com.techventus.server.voice.Voice.get(Voice.java:1159)  (System.err)
W( 7810) at com.techventus.server.voice.Voice.getRecent(Voice.java:391)  
(System.err)
W( 7810) at com.techventus.server.voice.Voice.isLoggedIn(Voice.java:1358)  
(System.err)
W( 7810) at 
com.techventus.locations.LocationService.updateLoginCredentials(LocationService.
java:789)  (System.err)
W( 7810) at 
com.techventus.locations.LocationService$2.run(LocationService.java:121)  
(System.err)
W( 7810) at java.util.Timer$TimerImpl.run(Timer.java:289)  (System.err)

When he runs the test script of the Google Voice Library, again with Multiple 
Accounts Enabled:

https://www.google.com/accounts/ClientLogin - OK
Logged in to Google - Auth token received
https://www.google.com/voice/ - Moved Temporarily
IO error creating voice! - https://www.google.com/voice/ : Moved Temporarily(302
) : InputStream was null : exiting.
Goodbye.

Original comment by malone.j...@gmail.com on 24 Aug 2010 at 5:50

GoogleCodeExporter commented 9 years ago
Joseph - it would be interesting to see if the new version can handle the 302 
fine and see a log of that happening. That problem never occurred in my own 
tests.

Original comment by teisentr...@gmail.com on 24 Aug 2010 at 5:57

GoogleCodeExporter commented 9 years ago
Latest commit (r123), I still get NullPointerException:

java.lang.NullPointerException
at 
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.rea
dln(HttpURLConnectionImpl.java:1279)
at 
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl$Chu
nkedInputStream.readChunkSize(HttpURLConnectionImpl.java:404)
at 
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl$Chu
nkedInputStream.<init>(HttpURLConnectionImpl.java:340)
at 
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.get
ContentStream(HttpURLConnectionImpl.java:1175)
at 
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.doR
equestInternal(HttpURLConnectionImpl.java:1754)
at 
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.doR
equest(HttpURLConnectionImpl.java:1649)
at 
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.get
ResponseCode(HttpURLConnectionImpl.java:1374)
at 
org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.g
etResponseCode(HttpsURLConnectionImpl.java:117)
at com.techventus.server.voice.Voice.get(Voice.java:1231)
at com.techventus.server.voice.Voice.getGeneral(Voice.java:432)
at com.techventus.server.voice.Voice.init(Voice.java:330)
at com.techventus.server.voice.Voice.<init>(Voice.java:256)
at com.realtynode.gvfree.gvdialer$2.run(gvdialer.java:247)

Original comment by gurur...@gmail.com on 26 Aug 2010 at 4:01

GoogleCodeExporter commented 9 years ago
Interesting - did you use the newest revision 123? 
http://code.google.com/p/google-voice-java/source/detail?r=123 
Line 1231 is this statement:
int responseCode = conn.getResponseCode();
which doesnt really make sense, because we have operated on conn before. Any 
thoughts? Are you able to debug this part?

The first Post had a line number where 'InputStream is' was null. This has been 
resolved. 
So should we close this issue and open a new one for your problem on revision 
123 com.techventus.server.voice.Voice.get(Voice.java:1231) ?

Original comment by teisentr...@gmail.com on 26 Aug 2010 at 5:29

GoogleCodeExporter commented 9 years ago
Yes, its with the latest revision 123.  I noticed this new NullPointerException 
started showing up around August 6th for me and would correspond to commit 
r120.  I'll open a new bug.

Original comment by gurur...@gmail.com on 26 Aug 2010 at 8:34