apache / apache/netbeans

NetworkProxyReloader ignores "No proxy"-setting in Windows 10 if pac-file is configured

Open
#5,511 0 comments 0 reactions 0 assignees View on GitHub
kind:bug needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 16

### What happened

I am implementing a netbeans platform application. I recognized an unexpected behavior on the startup of my application. The following lines are logged on every startup:

INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy - mode: auto
INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy - pac https://some/proxy.pac
INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy TEST - http host:
INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy TEST - http port: 0

This is strange, because I configured my application to use no proxy at all. This is the content of the config/Preferences/org/netbeans/core.properties file:

```
proxyType=0
systemPAC=
testSystemProxyHttpHost=
testSystemProxyHttpPort=0
```

So I had a look at the implementation of the NetworkProxyReloader an found the following in the class WindowsNetworkProxy:

```
@Override
public NetworkProxySettings getNetworkProxySettings() {
LOGGER.log(Level.FINE, "Windows system proxy resolver started."); //NOI18N
WindowsNetworkProxyLibrary.ProxyConfig.ByReference prxCnf = new WindowsNetworkProxyLibrary.ProxyConfig.ByReference();

boolean result = WindowsNetworkProxyLibrary.LIBRARY.WinHttpGetIEProxyConfigForCurrentUser(prxCnf);

if (result) {
LOGGER.log(Level.FINE, "Windows system proxy resolver successfully retrieved proxy settings."); //NOI18N

// QUESTION: shouldn't we check whether proxy is disabled before checking the windows settings at all?
if (prxCnf.autoDetect) {
LOGGER.log(Level.INFO, "Windows system proxy resolver: auto detect"); //NOI18N
}

Pointer pacFilePointer = prxCnf.pacFile;
if (pacFilePointer != null) {
// QUESTION: If there is a pac-file defined in the system proxy settings, netbeans seems to ignore the proxyType "DIRECT" completely
String pacFileUrl = pacFilePointer.getWideString(0);

LOGGER.log(Level.INFO, "Windows system proxy resolver: auto - PAC ({0})", pacFileUrl); //NOI18N
return new NetworkProxySettings(pacFileUrl);
}
```

I added two comments beginning with "QUESTION: ". It seems having a pac file configured globally leads netbeans to ignore the actual proxyType configured.
Am I right? If so, is there a workaround for leaving the global config as it is but let netbeans ignore it?

Why is this a problem? Since one of our customers has a bug in its pac file every start of the application raises an exception from the NashornEngine trying to execute the pac script. Fixing the pac script is possible but will take some time. The netbeans application itself only requests services reachable in the intranet of our customer. So, the proxy is not necessary for our application to work.

Best regards,
René

### How to reproduce

1. configure a netbeans platform application to use no proxy
2. add a pac file to your global windows internet confiig
3. start your application
4. look at the log

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Windows 10 (22H2 Build 19045.2364)

### JDK

11

### Apache NetBeans packaging

Apache NetBeans platform

### Anything else

Happens for all platform versions since RELEASE110. This might be an older bug, but I dont tested older versions of netbeans)

### Are you willing to submit a pull request?

No

### Code of Conduct

Yes

Contributor guide

Open the contributing guide

Research direction

Start with WindowsNetworkProxy.getNetworkProxySettings and the NetworkProxyReloader behavior described in the issue, then review how config/Preferences/org/netbeans/core.properties represents proxyType=0 alongside systemPAC. Reproduce on Windows 10 with a PAC file configured and no proxy selected; done means the application no longer processes the PAC file or logs it as the active proxy in that configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.