You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2020/03/28 10:08:53 UTC

[GitHub] [bookkeeper] sijie opened a new pull request #2301: Handle NPE when inet address is not able to resolve network address

sijie opened a new pull request #2301: Handle NPE when inet address is not able to resolve network address
URL: https://github.com/apache/bookkeeper/pull/2301
 
 
   
   
   Descriptions of the changes in this PR:
   
   *Motivation*
   
   ```
   06:00:53.731 [BookKeeperClientScheduler-OrderedScheduler-0-0] ERROR org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy - Unexpected exception while handling joining bookie pulsar-tls-bookie-0.pulsar-tls-bookie.pulsar.svc.cluster.local:3181
   java.lang.NullPointerException: null
   	at org.apache.bookkeeper.net.NetUtils.resolveNetworkLocation(NetUtils.java:77) ~[org.apache.bookkeeper-bookkeeper-server-4.10.0.jar:4.10.0]
   ```
   
   *TEST*
   
   The `getAddress` is final method. It is hard to mock.
   
   The method has been covered by other tests.
   
   > ---
   > In order to uphold a high standard for quality for code contributions, Apache BookKeeper runs various precommit
   > checks for pull requests. A pull request can only be merged when it passes precommit checks.
   >
   > ---
   > Be sure to do all of the following to help us incorporate your contribution
   > quickly and easily:
   >
   > If this PR is a BookKeeper Proposal (BP):
   >
   > - [ ] Make sure the PR title is formatted like:
   >     `<BP-#>: Description of bookkeeper proposal`
   >     `e.g. BP-1: 64 bits ledger is support`
   > - [ ] Attach the master issue link in the description of this PR.
   > - [ ] Attach the google doc link if the BP is written in Google Doc.
   >
   > Otherwise:
   > 
   > - [ ] Make sure the PR title is formatted like:
   >     `<Issue #>: Description of pull request`
   >     `e.g. Issue 123: Description ...`
   > - [ ] Make sure tests pass via `mvn clean apache-rat:check install spotbugs:check`.
   > - [ ] Replace `<Issue #>` in the title with the actual Issue number.
   > 
   > ---
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [bookkeeper] rdhabalia commented on a change in pull request #2301: Handle NPE when inet address is not able to resolve network address

Posted by GitBox <gi...@apache.org>.
rdhabalia commented on a change in pull request #2301: Handle NPE when inet address is not able to resolve network address
URL: https://github.com/apache/bookkeeper/pull/2301#discussion_r403169015
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/net/NetUtils.java
 ##########
 @@ -68,13 +68,20 @@ public static String normalizeHostName(String name) {
         return hostNames;
     }
 
-    public static String resolveNetworkLocation(DNSToSwitchMapping dnsResolver, InetSocketAddress addr) {
+    public static String resolveNetworkLocation(DNSToSwitchMapping dnsResolver,
+                                                BookieSocketAddress addr) {
         List<String> names = new ArrayList<String>(1);
 
+        InetSocketAddress inetSocketAddress = addr.getSocketAddress();
         if (dnsResolver.useHostName()) {
             names.add(addr.getHostName());
         } else {
-            names.add(addr.getAddress().getHostAddress());
+            InetAddress inetAddress = inetSocketAddress.getAddress();
+            if (null == inetAddress) {
+                addr.getHostName();
 
 Review comment:
   shouldn't we add into `names`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [bookkeeper] eolivelli commented on issue #2301: Handle NPE when inet address is not able to resolve network address

Posted by GitBox <gi...@apache.org>.
eolivelli commented on issue #2301: Handle NPE when inet address is not able to resolve network address
URL: https://github.com/apache/bookkeeper/pull/2301#issuecomment-608548635
 
 
   @sijie CI is failing with this error:
   `[ERROR] Return value of BookieSocketAddress.getHostName() ignored, but method has no side effect [org.apache.bookkeeper.net.NetUtils] At NetUtils.java:[line 81] RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [bookkeeper] sijie commented on a change in pull request #2301: Handle NPE when inet address is not able to resolve network address

Posted by GitBox <gi...@apache.org>.
sijie commented on a change in pull request #2301: Handle NPE when inet address is not able to resolve network address
URL: https://github.com/apache/bookkeeper/pull/2301#discussion_r403171533
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/net/NetUtils.java
 ##########
 @@ -68,13 +68,20 @@ public static String normalizeHostName(String name) {
         return hostNames;
     }
 
-    public static String resolveNetworkLocation(DNSToSwitchMapping dnsResolver, InetSocketAddress addr) {
+    public static String resolveNetworkLocation(DNSToSwitchMapping dnsResolver,
+                                                BookieSocketAddress addr) {
         List<String> names = new ArrayList<String>(1);
 
+        InetSocketAddress inetSocketAddress = addr.getSocketAddress();
         if (dnsResolver.useHostName()) {
             names.add(addr.getHostName());
         } else {
-            names.add(addr.getAddress().getHostAddress());
+            InetAddress inetAddress = inetSocketAddress.getAddress();
+            if (null == inetAddress) {
+                addr.getHostName();
 
 Review comment:
   We need to add it to `names`. I will fix it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services