Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000988 [Resin] minor always 03-13-06 13:42 04-03-06 16:39
Reporter igor View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version
Summary 0000988: Authentication Exception 401 reporting problem
Description Use Case:

1. Setting authentication data:

            HessianProxyFactory factory = new HessianProxyFactory();
            String url = (String) props.get("url");
            String user = (String) props.get("username");
            String pwd = (String) props.get("password");
            factory.setUser(user);
            factory.setPassword(pwd);

            return factory.create(clazz, url);


2. Calling <aService>.<aMethod> (no streams, regular web services call)

3. Using wrong user/password in order to test getting 401 error

4. Reported error does not contain error cause

Code analysis
================
(see HessianProxy code fragment)
(1) code = 401
(2) empty buffer
(3) is = null
(4) catch (IOException e) {} ==> this is original code, "null" action
(5) throw exception with no details specified: buffer is empty and error code
is not passed.

Code change
===========
catch (IOException e) {
              // added 3/13/06 (4)
              if (is == null) {
                  throw new HessianProtocolException(e.getCause());
              }
          }

HessianProtocolException is wrapped round root cause exception and is propagated to client code.


HessianProxy code fragment
==========================

      if (conn instanceof HttpURLConnection) {
        HttpURLConnection httpConn = (HttpURLConnection) conn;
        int code = 500;

        try {
          code = httpConn.getResponseCode(); // (1)
        } catch (Exception e) {
        }

        if (code != 200) {
          StringBuffer sb = new StringBuffer(); (2)
          int ch;

          try {
            is = httpConn.getInputStream(); // (3)

            if (is != null) {
              while ((ch = is.read()) >= 0)
                sb.append((char) ch);

              is.close();
            }

            is = httpConn.getErrorStream();
            if (is != null) {
              while ((ch = is.read()) >= 0)
                sb.append((char) ch);
            }
          } catch (FileNotFoundException e) {
            throw new HessianRuntimeException(String.valueOf(e));
          } catch (IOException e) {
              // added 3/13/06 (4)
              if (is == null) {
                  throw new HessianProtocolException(e.getCause());
              }
          }

          if (is != null)
            is.close();

          throw new HessianProtocolException(sb.toString()); // (5)
        }
      }
Additional Information
Attached Files

- Relationships

- Notes
(0001002)
ferg
04-03-06 16:39

ejb/3442
 

- Issue History
Date Modified Username Field Change
03-13-06 13:42 igor New Issue
04-03-06 16:39 ferg Note Added: 0001002
04-03-06 16:39 ferg Assigned To  => ferg
04-03-06 16:39 ferg Status new => closed
04-03-06 16:39 ferg Resolution open => fixed
04-03-06 16:39 ferg Fixed in Version  => 3.0.19


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
29 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker