Issue Details (XML | Word | Printable)

Key: NET-67
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Jose M. Ordax
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Net

[net] Problem calculating total article count

Created: 10/Nov/04 09:45 PM   Updated: 20/Sep/07 05:31 AM
Return to search
Component/s: None
Affects Version/s: 1.2
Fix Version/s: None

Time Tracking:
Not Specified

Environment:
Operating System: All
Platform: All

Bugzilla Id: 32152


 Description  « Hide
I am using Commons Net 1.2.2

When you ask for the list of newsgroups of a NNTP Server, the framework doesn't
calculate correctly the total article count when that specific newsgroup has no
articles.

For example, the NNTP Server answers something like this:

org.javahispano.j2ee 0 0 y

then, debugging the source code of class:

org.apache.commons.net.nntp.NNTPClient

I found the problem in method:

private NewsgroupInfo __parseNewsgroupListEntry(String entry)

where it does:

...
result._setNewsgroup(tokenizer.nextToken());
last = tokenizer.nextToken();
first = tokenizer.nextToken();
permission = tokenizer.nextToken();

try

{ lastNum = Integer.parseInt(last); firstNum = Integer.parseInt(first); result._setFirstArticle(firstNum); result._setLastArticle(lastNum); result._setArticleCount(lastNum - firstNum + 1); }

catch (NumberFormatException e)

{ return null; }

The proble is in this line:

result._setArticleCount(lastNum - firstNum + 1);

where if lastNum is 0 and firstNum is 0, it sais that the newsgroup has 1
article. I understand the code should add a control line where it double check
if lastNum and firstNum are 0. Right?



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Rory Winston added a comment - 26/Nov/04 06:41 PM
You're right, I will put a check for that condition in there. Thanks.