Skip to content

Commit 9ae7e1d

Browse files
committed
Suppress or replace generic array creation
1 parent a1db745 commit 9ae7e1d

2 files changed

Lines changed: 14 additions & 18 deletions

File tree

src/main/java/org/xbill/DNS/Message.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ public Message normalize(Message query, boolean throwOnIrrelevantRecord)
810810
List<RRset> additionalSectionSets = getSectionRRsets(Section.ADDITIONAL);
811811
List<RRset> authoritySectionSets = getSectionRRsets(Section.AUTHORITY);
812812

813-
@SuppressWarnings("unchecked")
813+
@SuppressWarnings({"unchecked", "rawtypes"})
814814
List<RRset>[] cleanedSection = new ArrayList[4];
815815
cleanedSection[Section.ANSWER] = new ArrayList<>();
816816
cleanedSection[Section.AUTHORITY] = new ArrayList<>();

src/main/java/org/xbill/DNS/NioClient.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public abstract class NioClient {
4545

4646
private static final Runnable[] TIMEOUT_TASKS = new Runnable[2];
4747

48-
@SuppressWarnings("unchecked")
49-
private static final Consumer<Selector>[] REGISTRATIONS_TASKS = new Consumer[2];
48+
private static Consumer<Selector> TCP_REGISTRATIONS_TASK;
49+
private static Consumer<Selector> UDP_REGISTRATIONS_TASK;
5050

5151
private static final Runnable[] CLOSE_TASKS = new Runnable[2];
5252
private static Thread selectorThread;
@@ -193,7 +193,11 @@ static void setTimeoutTask(Runnable r, boolean isTcpClient) {
193193
}
194194

195195
static void setRegistrationsTask(Consumer<Selector> r, boolean isTcpClient) {
196-
addRegistrationTask(r, isTcpClient);
196+
if (isTcpClient) {
197+
TCP_REGISTRATIONS_TASK = r;
198+
} else {
199+
UDP_REGISTRATIONS_TASK = r;
200+
}
197201
}
198202

199203
static void setCloseTask(Runnable r, boolean isTcpClient) {
@@ -208,14 +212,6 @@ private static void addTask(Runnable[] tasks, Runnable r, boolean isTcpClient) {
208212
}
209213
}
210214

211-
private static void addRegistrationTask(Consumer<Selector> r, boolean isTcpClient) {
212-
if (isTcpClient) {
213-
REGISTRATIONS_TASKS[0] = r;
214-
} else {
215-
REGISTRATIONS_TASKS[1] = r;
216-
}
217-
}
218-
219215
private static void runTasks(Runnable[] runnables) {
220216
Runnable r0 = runnables[0];
221217
if (r0 != null) {
@@ -228,13 +224,13 @@ private static void runTasks(Runnable[] runnables) {
228224
}
229225

230226
private static void runRegistrationTasks() {
231-
Consumer<Selector> r0 = REGISTRATIONS_TASKS[0];
232-
if (r0 != null) {
233-
r0.accept(selector);
227+
Consumer<Selector> tcpTask = TCP_REGISTRATIONS_TASK;
228+
if (tcpTask != null) {
229+
tcpTask.accept(selector);
234230
}
235-
Consumer<Selector> r1 = REGISTRATIONS_TASKS[1];
236-
if (r1 != null) {
237-
r1.accept(selector);
231+
Consumer<Selector> udpTask = UDP_REGISTRATIONS_TASK;
232+
if (udpTask != null) {
233+
udpTask.accept(selector);
238234
}
239235
}
240236

0 commit comments

Comments
 (0)