Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
Dev: fix findbugs issues
Browse files Browse the repository at this point in the history
  • Loading branch information
andriydruk committed Nov 12, 2018
1 parent 5737ce2 commit ab90154
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 74 deletions.
2 changes: 1 addition & 1 deletion dnssd/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ task findbugs(type: FindBugs) {
enabled = true
}
}
classes = files("${project.projectDir}/build/intermediates/classes/debug/com/github")
classes = files("${project.projectDir}/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/github/druk/dnssd")
source = fileTree('src/main/java/com/github')
classpath = files()
excludeFilter = file("${buildscript.sourceFile.parent}/findbugs-filter.xml")
Expand Down
12 changes: 12 additions & 0 deletions dnssd/findbugs-filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,16 @@
<Class name="com.github.druk.dnssd.TXTRecord" />
</Match>

<Match>
<Class name="com.github.druk.dnssd.DNSSD" />
<Method name="resolve" />
<Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON" />
</Match>

<Match>
<Class name="com.github.druk.dnssd.DNSSD" />
<Method name="onServiceStarting" />
<Bug pattern="DC_PARTIALLY_CONSTRUCTED" />
</Match>

</FindBugsFilter>
7 changes: 1 addition & 6 deletions dnssd/src/main/java/com/github/druk/dnssd/DNSSD.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,7 @@ public DNSSDService resolve(int flags, int ifIndex, String serviceName, String r
onServiceStarting();
final DNSSDService[] services = new DNSSDService[1];

final Runnable timeoutRunnable = new Runnable() {
@Override
public void run() {
services[0].stop();
}
};
final Runnable timeoutRunnable = () -> services[0].stop();

services[0] = new InternalDNSSDService(this, InternalDNSSD.resolve(flags, ifIndex, serviceName, regType, domain, new InternalResolveListener() {
@Override
Expand Down
14 changes: 8 additions & 6 deletions dnssd/src/main/java/com/github/druk/dnssd/DNSSDEmbedded.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,17 @@ public void run() {
public void exit() {
synchronized (DNSSDEmbedded.class) {
mStopTimer = new Timer();
mStopTimer.schedule(new TimerTask() {
@Override
public void run() {
nativeExit();
}
}, mStopTimerDelay);
mStopTimer.schedule(exitTask, mStopTimerDelay);
}
}

private static final TimerTask exitTask = new TimerTask() {
@Override
public void run() {
nativeExit();
}
};

private void waitUntilStarted() {
synchronized (DNSSDEmbedded.class) {
while (!isStarted) {
Expand Down
17 changes: 9 additions & 8 deletions dnssd/src/main/java/com/github/druk/dnssd/NSClass.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.github.druk.dnssd;

// Copied from nameser.h
@SuppressWarnings(value = "")
public class NSClass {

public static int INVALID = 0; /* Cookie. */
public static int IN = 1; /* Internet. */
public static int CLASS2 = 2; /* unallocated/unsupported. */
public static int CHAOS = 3; /* MIT Chaos-net. */
public static int HS = 4; /* MIT Hesiod. */
public final static int INVALID = 0; /* Cookie. */
public final static int IN = 1; /* Internet. */
public final static int CLASS2 = 2; /* unallocated/unsupported. */
public final static int CHAOS = 3; /* MIT Chaos-net. */
public final static int HS = 4; /* MIT Hesiod. */
/* Query class values which do not appear in resource records */
public static int NONE = 254; /* for prereq. sections in update requests */
public static int ANY = 255; /* Wildcard match. */
public static int MAX = 65536;
public final static int NONE = 254; /* for prereq. sections in update requests */
public final static int ANY = 255; /* Wildcard match. */
public final static int MAX = 65536;
}
102 changes: 51 additions & 51 deletions dnssd/src/main/java/com/github/druk/dnssd/NSType.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,56 @@
// Copied from nameser.h
public class NSType {

public static int INVALID = 0; /* Cookie. */
public static int A = 1; /* Host address. */
public static int NS = 2; /* Authoritative server. */
public static int MD = 3; /* Mail destination. */
public static int MF = 4; /* Mail forwarder. */
public static int CNAME = 5; /* Canonical name. */
public static int SOA = 6; /* Start of authority zone. */
public static int MB = 7; /* Mailbox domain name. */
public static int MG = 8; /* Mail group member. */
public static int MR = 9; /* Mail rename name. */
public static int NULL = 10; /* Null resource record. */
public static int WKS = 11; /* Well known service. */
public static int PTR = 12; /* Domain name pointer. */
public static int HINFO = 13; /* Host information. */
public static int MINFO = 14; /* Mailbox information. */
public static int MX = 15; /* Mail routing information. */
public static int TXT = 16; /* Text strings. */
public static int RP = 17; /* Responsible person. */
public static int AFSDB = 18; /* AFS cell database. */
public static int X25 = 19; /* X_25 calling address. */
public static int ISDN = 20; /* ISDN calling address. */
public static int RT = 21; /* Router. */
public static int NSAP = 22; /* NSAP address. */
public static int NSAP_PTR = 23; /* Reverse NSAP lookup = deprecated). */
public static int SIG = 24; /* Security signature. */
public static int KEY = 25; /* Security key. */
public static int PX = 26; /* X.400 mail mapping. */
public static int GPOS = 27; /* Geographical position = withdrawn). */
public static int AAAA = 28; /* Ip6 Address. */
public static int LOC = 29; /* Location Information. */
public static int NXT = 30; /* Next domain (security). */
public static int EID = 31; /* Endpoint identifier. */
public static int NIMLOC = 32; /* Nimrod Locator. */
public static int SRV = 33; /* Server Selection. */
public static int ATMA = 34; /* ATM Address */
public static int NAPTR = 35; /* Naming Authority PoinTeR */
public static int KX = 36; /* Key Exchange */
public static int CERT = 37; /* Certification record */
public static int A6 = 38; /* IPv6 address = deprecates AAAA) */
public static int DNAME = 39; /* Non-terminal DNAME (for IPv6) */
public static int SINK = 40; /* Kitchen sink (experimentatl) */
public static int OPT = 41; /* EDNS0 option (meta-RR) */
public static int TKEY = 249; /* Transaction key */
public static int TSIG = 250; /* Transaction signature. */
public static int IXFR = 251; /* Incremental zone transfer. */
public static int AXFR = 252; /* Transfer zone of authority. */
public static int MAILB = 253; /* Transfer mailbox records. */
public static int MAILA = 254; /* Transfer mail agent records. */
public static int ANY = 255; /* Wildcard match. */
public static int ZXFR = 256; /* BIND-specific, nonstandard. */
public static int MAX = 65536;
public final static int INVALID = 0; /* Cookie. */
public final static int A = 1; /* Host address. */
public final static int NS = 2; /* Authoritative server. */
public final static int MD = 3; /* Mail destination. */
public final static int MF = 4; /* Mail forwarder. */
public final static int CNAME = 5; /* Canonical name. */
public final static int SOA = 6; /* Start of authority zone. */
public final static int MB = 7; /* Mailbox domain name. */
public final static int MG = 8; /* Mail group member. */
public final static int MR = 9; /* Mail rename name. */
public final static int NULL = 10; /* Null resource record. */
public final static int WKS = 11; /* Well known service. */
public final static int PTR = 12; /* Domain name pointer. */
public final static int HINFO = 13; /* Host information. */
public final static int MINFO = 14; /* Mailbox information. */
public final static int MX = 15; /* Mail routing information. */
public final static int TXT = 16; /* Text strings. */
public final static int RP = 17; /* Responsible person. */
public final static int AFSDB = 18; /* AFS cell database. */
public final static int X25 = 19; /* X_25 calling address. */
public final static int ISDN = 20; /* ISDN calling address. */
public final static int RT = 21; /* Router. */
public final static int NSAP = 22; /* NSAP address. */
public final static int NSAP_PTR = 23; /* Reverse NSAP lookup = deprecated). */
public final static int SIG = 24; /* Security signature. */
public final static int KEY = 25; /* Security key. */
public final static int PX = 26; /* X.400 mail mapping. */
public final static int GPOS = 27; /* Geographical position = withdrawn). */
public final static int AAAA = 28; /* Ip6 Address. */
public final static int LOC = 29; /* Location Information. */
public final static int NXT = 30; /* Next domain (security). */
public final static int EID = 31; /* Endpoint identifier. */
public final static int NIMLOC = 32; /* Nimrod Locator. */
public final static int SRV = 33; /* Server Selection. */
public final static int ATMA = 34; /* ATM Address */
public final static int NAPTR = 35; /* Naming Authority PoinTeR */
public final static int KX = 36; /* Key Exchange */
public final static int CERT = 37; /* Certification record */
public final static int A6 = 38; /* IPv6 address = deprecates AAAA) */
public final static int DNAME = 39; /* Non-terminal DNAME (for IPv6) */
public final static int SINK = 40; /* Kitchen sink (experimentatl) */
public final static int OPT = 41; /* EDNS0 option (meta-RR) */
public final static int TKEY = 249; /* Transaction key */
public final static int TSIG = 250; /* Transaction signature. */
public final static int IXFR = 251; /* Incremental zone transfer. */
public final static int AXFR = 252; /* Transfer zone of authority. */
public final static int MAILB = 253; /* Transfer mailbox records. */
public final static int MAILA = 254; /* Transfer mail agent records. */
public final static int ANY = 255; /* Wildcard match. */
public final static int ZXFR = 256; /* BIND-specific, nonstandard. */
public final static int MAX = 65536;

}
2 changes: 1 addition & 1 deletion rx2dnssd/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ task findbugs(type: FindBugs) {
enabled = true
}
}
classes = files("${project.projectDir}/build/intermediates/classes/debug/com/github")
classes = files("${project.projectDir}/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/github/druk/rx2dnssd")
source = fileTree('src/main/java/com/github')
classpath = files()
excludeFilter = file("${buildscript.sourceFile.parent}/findbugs-filter.xml")
Expand Down
2 changes: 1 addition & 1 deletion rxdnssd/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ task findbugs(type: FindBugs) {
enabled = true
}
}
classes = files("${project.projectDir}/build/intermediates/classes/debug/com/github")
classes = files("${project.projectDir}/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/github/druk/rxdnssd")
source = fileTree('src/main/java/com/github')
classpath = files()
excludeFilter = file("${buildscript.sourceFile.parent}/findbugs-filter.xml")
Expand Down

0 comments on commit ab90154

Please sign in to comment.