Commons Net
  1. Commons Net
  2. NET-276

NNTPClient has problems with group listings for large groups.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 3.0
    • Component/s: NNTP
    • Labels:
      None

      Description

      The following command causes a MalformedServerReplyException on my usenet server (astraweb):
      client.listNewsgroups();

      Root Cause:
      Caused by: org.apache.commons.net.MalformedServerReplyException: alt.binaries.boneless 2230918506 1662764743 y
      at org.apache.commons.net.nntp.NNTPClient.__readNewsgroupListing(NNTPClient.java:255)
      at org.apache.commons.net.nntp.NNTPClient.listNewsgroups(NNTPClient.java:930)
      at org.lievaart.jleecher.protocol.CommandFactory$2.doOnServer(CommandFactory.java:27)
      at org.lievaart.jleecher.protocol.NNTPProtocol.callServer(NNTPProtocol.java:33)
      ... 2 more

      My hypothesis is that NNTP cannot parse the response, because one of the numbers exceeds the Integer range.
      Locally I have applied the following quick fix to get it to work:

      public class NNTPClient extends NNTP {
      ...
      ...
      ...
      private NewsgroupInfo __parseNewsgroupListEntry(final String entry) {
      NewsgroupInfo result;
      StringTokenizer tokenizer;
      int lastNum, firstNum;
      String last, first, permission;

      result = new NewsgroupInfo();
      tokenizer = new StringTokenizer(entry);

      if (tokenizer.countTokens() < 4)

      { return null; }

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

      try {
      try

      { lastNum = Integer.parseInt(last); }

      catch (NumberFormatException nfe) {
      if (last.matches("
      d++"))

      { lastNum = Integer.MAX_VALUE; }

      else

      { throw nfe; }

      }

        Issue Links

          Activity

          Hide
          Erik added a comment -

          As of today, I also need to do this check when parsing firstNum.
          Please note that my quick fix prevents the group listing from throwing a MalformedServerReplyException,
          but at the same time makes it impossible to retrieve articles from the alt.binaries.boneless group.

          Show
          Erik added a comment - As of today, I also need to do this check when parsing firstNum. Please note that my quick fix prevents the group listing from throwing a MalformedServerReplyException, but at the same time makes it impossible to retrieve articles from the alt.binaries.boneless group.
          Hide
          Rory Winston added a comment -

          Changed all article count fields to use long instead of int.

          Show
          Rory Winston added a comment - Changed all article count fields to use long instead of int.
          Hide
          Sebb added a comment -

          The change broke binary compatibility, so cannot be part of a 2.x release.
          Also, the change was incomplete, as not all instances of article numbers etc. were changed.

          Show
          Sebb added a comment - The change broke binary compatibility, so cannot be part of a 2.x release. Also, the change was incomplete, as not all instances of article numbers etc. were changed.
          Hide
          Sebb added a comment -

          Fixed, and examples updated and working AFAICT

          Show
          Sebb added a comment - Fixed, and examples updated and working AFAICT
          Hide
          BattousaiX added a comment -

          I have tried your code, but there is an error with the following line.
          result._setNewsgroup(tokenizer.nextToken());
          _setNewsgroup method is not visible.

          Were any other modifications made?

          Show
          BattousaiX added a comment - I have tried your code, but there is an error with the following line. result._setNewsgroup(tokenizer.nextToken()); _setNewsgroup method is not visible. Were any other modifications made?
          Show
          Sebb added a comment - See SVN trunk for the current code. http://svn.apache.org/repos/asf/commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp

            People

            • Assignee:
              Unassigned
              Reporter:
              Erik
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development