Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2071)

Issue 2255041: StreamProxy should not NPE when socket is closed without request (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 7 months ago by jeremy.wadsack
Modified:
13 years, 7 months ago
Reviewers:
Michael Frederick
Base URL:
http://npr-android-app.googlecode.com/svn/trunk/
Visibility:
Public.

Description

In testing I found the the StreamProxy class was throwing a NullPointerException when trying to parse a null through StringTokenizer. This happens when the client connects to the proxy and disconnects without ever sending a request. I suspect this would never happen in the app, but should be checked so that other tests can do this action. This patch includes a test case to check for the problem and a patch. It also includes some code cleanup (created a constant for the logging in StreamProxy to match the other classes).

Patch Set 1 #

Total comments: 15

Patch Set 2 : Updated to reflect comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+80 lines, -22 lines) Patch
Npr/src/org/npr/android/news/StreamProxy.java View 8 chunks +26 lines, -20 lines 0 comments Download
Npr_Test/src/org/npr/android/news/StreamProxyTest.java View 1 4 chunks +54 lines, -2 lines 0 comments Download

Messages

Total messages: 6
jeremy.wadsack
13 years, 7 months ago (2010-09-20 22:20:45 UTC) #1
Michael Frederick
Nice! A few comments. http://codereview.appspot.com/2255041/diff/1/Npr_Test/src/org/npr/android/news/StreamProxyTest.java File Npr_Test/src/org/npr/android/news/StreamProxyTest.java (right): http://codereview.appspot.com/2255041/diff/1/Npr_Test/src/org/npr/android/news/StreamProxyTest.java#newcode33 Npr_Test/src/org/npr/android/news/StreamProxyTest.java:33: private boolean caughtNPE = false; ...
13 years, 7 months ago (2010-09-21 00:38:09 UTC) #2
jeremy.wadsack
Updated to reflect comments and new patch set pushed. Note that I can't do an ...
13 years, 7 months ago (2010-09-21 17:30:01 UTC) #3
Michael Frederick
LGTM One more question. http://codereview.appspot.com/2255041/diff/1/Npr_Test/src/org/npr/android/news/StreamProxyTest.java File Npr_Test/src/org/npr/android/news/StreamProxyTest.java (right): http://codereview.appspot.com/2255041/diff/1/Npr_Test/src/org/npr/android/news/StreamProxyTest.java#newcode47 Npr_Test/src/org/npr/android/news/StreamProxyTest.java:47: Thread.setDefaultUncaughtExceptionHandler(new ThreadExceptionHandler()); On 2010/09/21 17:30:01, ...
13 years, 7 months ago (2010-09-21 17:36:35 UTC) #4
jeremy.wadsack
I don't think so. I can't add a public variable or method there, so to ...
13 years, 7 months ago (2010-09-21 18:42:30 UTC) #5
Michael Frederick
13 years, 7 months ago (2010-09-21 18:44:19 UTC) #6
Agreed. Thanks!

On Tue, Sep 21, 2010 at 2:42 PM, Jeremy Wadsack <jeremy.wadsack@gmail.com>wrote:

> I don't think so. I can't add a public variable or method there, so to do
> that the caughtNPE boolean either needs to be local and final (in which case
> it can't be set) or it needs to be a class variable on the containing class.
> It's one or the other and I think having the state within the class is
> cleaner than having an anonymous class set the containing class's member
> variable.
>
> --
> Jeremy Wadsack
>
>
>
> On Tue, Sep 21, 2010 at 10:36 AM, <mfrederick@google.com> wrote:
>
>> LGTM
>>
>> One more question.
>>
>>
>>
>>
>>
http://codereview.appspot.com/2255041/diff/1/Npr_Test/src/org/npr/android/new...
>> File Npr_Test/src/org/npr/android/news/StreamProxyTest.java (right):
>>
>>
>>
http://codereview.appspot.com/2255041/diff/1/Npr_Test/src/org/npr/android/new...
>> Npr_Test/src/org/npr/android/news/StreamProxyTest.java:47:
>> Thread.setDefaultUncaughtExceptionHandler(new ThreadExceptionHandler());
>> On 2010/09/21 17:30:01, jeremy.wadsack wrote:
>>
>>> On 2010/09/21 00:38:09, Michael Frederick wrote:
>>> > Rather than use an inner class, I would prefer an inline class here.
>>>
>>
>>  I can't use an inline class (although it would keep the test cleaner)
>>>
>> because it
>>
>>> needs to set the caughtNPE value. That can't be in an inline class
>>>
>> because it's
>>
>>> of type UncaughtExceptionHandler. And it can't be in the containing
>>>
>> class
>>
>>> because it would have to be final then.
>>>
>>
>> Can't you do:
>> Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler()
>> {
>>   @Override
>>   public void uncaughtException(Thread thread, Throwable ex) { ... }
>> });
>>
>>
>> http://codereview.appspot.com/2255041/
>>
>
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b