Skip to content

Fix NPE with no active network interfaces and HostnameFetcher Java 17+ reflection fallback#518

Merged
angryziber merged 1 commit into
masterfrom
copilot/find-reported-issues
Jun 8, 2026
Merged

Fix NPE with no active network interfaces and HostnameFetcher Java 17+ reflection fallback#518
angryziber merged 1 commit into
masterfrom
copilot/find-reported-issues

Conversation

Copilot AI commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Two independent crash bugs, both caused by implicit assumptions that break in edge-case environments.

NPE when all interfaces are DOWN (#340)

InetAddressUtils.getLocalInterface() returns null when no non-loopback interface with a hardware address is up. AbstractFeederGUI.asyncFillLocalHostInfo() dereferenced it unconditionally in both the UnknownHostException catch block and the asyncExec callback.

// Before
catch (UnknownHostException e) {
    localName = localInterface.getAddress().getHostName(); // NPE if null
}
// asyncExec
if ("".equals(ipText.getText())) {
    ipText.setText(localInterface.getAddress().getHostAddress()); // NPE if null
}

// After
catch (UnknownHostException e) {
    localName = localInterface != null ? localInterface.getAddress().getHostName() : "localhost";
}
if ("".equals(ipText.getText()) && localInterface != null) {
    ipText.setText(localInterface.getAddress().getHostAddress());
    afterLocalHostInfoFilled(localInterface);
}

HostnameFetcher silent NPE on Java 17+

On Java 17+, the HostnameFetcher static initializer fails with InaccessibleObjectException (module system blocks InetAddress.impl), leaving getHostByAddr = null. resolveWithRegularDNS() relied on the subsequent NPE being swallowed by a broad catch (Exception e) to fall through to getCanonicalHostName(). Replaced with an explicit if (getHostByAddr != null) guard so the fallback is unconditional and the exception handling only covers the intended InvocationTargetException/UnknownHostException path.

Copilot AI changed the title Fix reported exception bugs: Gradle 9 compat, NPE with no network interfaces, HostnameFetcher Java 17 Fix NPE with no active network interfaces, HostnameFetcher Java 17+ reflection, and Gradle 9 compat Jun 8, 2026
Copilot AI requested a review from angryziber June 8, 2026 06:59
…ameFetcher reflection fallback

- Fix build.gradle to use java {} block for source/target compatibility (issue #516)
- Fix NPE in AbstractFeederGUI.asyncFillLocalHostInfo() when no active network
  interfaces exist: localInterface can be null, causing NPE in the UnknownHostException
  catch block and in the asyncExec callback (issue #340)
- Fix HostnameFetcher.resolveWithRegularDNS() to explicitly guard the reflection
  path when getHostByAddr is null (Java 17+ module system incompatibility)
Copilot AI force-pushed the copilot/find-reported-issues branch from c82c4db to daaedd9 Compare June 8, 2026 07:51
Copilot AI changed the title Fix NPE with no active network interfaces, HostnameFetcher Java 17+ reflection, and Gradle 9 compat Fix NPE with no active network interfaces and HostnameFetcher Java 17+ reflection fallback Jun 8, 2026
@angryziber angryziber marked this pull request as ready for review June 8, 2026 08:42
@angryziber angryziber merged commit 2a73aa8 into master Jun 8, 2026
8 of 9 checks passed
@angryziber angryziber deleted the copilot/find-reported-issues branch June 8, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants