Permalink
Browse files

do not fail if mac column is selected, but value is n/a

  • Loading branch information...
1 parent 5a17df4 commit c44cd83b62be78c02b2731869511ea9ce1e24451 @angryziber committed Jun 5, 2015
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/net/azib/ipscan/config/CommentsConfig.java
@@ -36,8 +36,13 @@ public String getComment(InetAddress address, String mac) {
public String getComment(ScanningResultList results, int resultIndex) {
ScanningResult result = results.getResult(resultIndex);
int macIndex = results.getFetcherIndex(MACFetcher.ID);
- String mac = macIndex >= 0 ? (String) result.getValues().get(macIndex) : null;
- return getComment(result.getAddress(), mac);
+ return getComment(result.getAddress(), getMac(macIndex, result));
+ }
+
+ private String getMac(int macIndex, ScanningResult result) {
+ if (macIndex < 0) return null;
+ Object macValue = result.getValues().get(macIndex);
+ return macValue instanceof String ? (String) macValue : null;
}
public void setComment(ScanningResultList results, int resultIndex, String comment) {
@@ -49,7 +54,7 @@ public void setComment(ScanningResultList results, int resultIndex, String comme
if (macIndex >= 0) {
// remove ip-based comment if we set a mac-based one
preferences.remove(key);
- String mac = (String) result.getValues().get(macIndex);
+ String mac = getMac(macIndex, result);
if (mac != null) key = mac;
}

0 comments on commit c44cd83

Please sign in to comment.