Skip to content

Commit a48fbc2

Browse files
eclipse-platform-botHeikoKlare
authored andcommitted
Perform clean code of team/bundles/org.eclipse.core.net
1 parent fea5a61 commit a48fbc2

File tree

9 files changed

+172
-92
lines changed

9 files changed

+172
-92
lines changed

team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Activator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ private void log(IStatus status) {
107107
log.log(getLog(status));
108108
} else {
109109
System.out.println(status.getMessage());
110-
if (status.getException() != null)
110+
if (status.getException() != null) {
111111
status.getException().printStackTrace();
112+
}
112113
}
113114
}
114115

team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceManager.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,17 @@ void migrateInstanceScopePreferences(Preferences instanceScope, Preferences conf
262262
// migrate enabled status
263263
if (configuration.get(ProxyManager.PREF_ENABLED, null) == null) {
264264
String instanceEnabled = instanceScope.get(ProxyManager.PREF_ENABLED, null);
265-
if (instanceEnabled != null)
265+
if (instanceEnabled != null) {
266266
configuration.put(ProxyManager.PREF_ENABLED, instanceEnabled);
267+
}
267268
}
268269

269270
// migrate enabled status
270271
if (configuration.get(ProxyManager.PREF_OS, null) == null) {
271272
String instanceEnabled = instanceScope.get(ProxyManager.PREF_OS, null);
272-
if (instanceEnabled != null)
273+
if (instanceEnabled != null) {
273274
configuration.put(ProxyManager.PREF_OS, instanceEnabled);
275+
}
274276
}
275277

276278
// migrate non proxied hosts if not already set
@@ -288,8 +290,9 @@ void migrateInstanceScopePreferences(Preferences instanceScope, Preferences conf
288290
if (data.getHost() == null) {
289291
ProxyType instanceType = new ProxyType(type.getName(), instanceManager);
290292
IProxyData instanceData = instanceType.getProxyData(ProxyType.DO_NOT_VERIFY);
291-
if (instanceData.getHost() != null)
293+
if (instanceData.getHost() != null) {
292294
type.setProxyData(instanceData);
295+
}
293296
}
294297
}
295298

@@ -306,8 +309,9 @@ void migrateInstanceScopePreferences(Preferences instanceScope, Preferences conf
306309
private void migrateUpdateHttpProxy(Preferences instanceScope, ProxyType[] proxies, boolean isInitialize) {
307310
if (!instanceScope.getBoolean(PREF_HAS_MIGRATED, false)) {
308311
// Only set the migration bit when initializing
309-
if (isInitialize)
312+
if (isInitialize) {
310313
instanceScope.putBoolean(PREF_HAS_MIGRATED, true);
314+
}
311315
String httpProxyHost = getHostToMigrate(isInitialize /* checkSystemProperties */);
312316
int port = getPortToMigrate(isInitialize /* checkSystemProperties */);
313317
boolean httpProxyEnable = getEnablementToMigrate(isInitialize /* checkSystemProperties */);
@@ -331,8 +335,9 @@ private String getHostToMigrate(boolean checkSystemProperties) {
331335
if (checkSystemProperties && "".equals(httpProxyHost)) { //$NON-NLS-1$
332336
httpProxyHost = System.getProperty("http.proxyHost", ""); //$NON-NLS-1$ //$NON-NLS-2$
333337
}
334-
if ("".equals(httpProxyHost)) //$NON-NLS-1$
338+
if ("".equals(httpProxyHost)) { //$NON-NLS-1$
335339
httpProxyHost = null;
340+
}
336341
return httpProxyHost;
337342
}
338343

@@ -342,12 +347,13 @@ private int getPortToMigrate(boolean checkSystemProperties) {
342347
httpProxyPort = System.getProperty("http.proxyPort", ""); //$NON-NLS-1$ //$NON-NLS-2$
343348
}
344349
int port = -1;
345-
if (httpProxyPort != null && !"".equals(httpProxyPort)) //$NON-NLS-1$
350+
if (httpProxyPort != null && !"".equals(httpProxyPort)) { //$NON-NLS-1$
346351
try {
347352
port = Integer.parseInt(httpProxyPort);
348353
} catch (NumberFormatException e) {
349354
// Ignore
350355
}
356+
}
351357
return port;
352358
}
353359

team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyData.java

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ public void setType(String type) {
7070

7171
@Override
7272
public void setHost(String host) {
73-
if (host != null && host.length() == 0)
73+
if (host != null && host.length() == 0) {
7474
host = null;
75+
}
7576
this.host = host;
7677
}
7778

@@ -161,44 +162,60 @@ public int hashCode() {
161162

162163
@Override
163164
public boolean equals(Object obj) {
164-
if (this == obj)
165+
if (this == obj) {
165166
return true;
166-
if (obj == null)
167+
}
168+
if (obj == null) {
167169
return false;
168-
if (getClass() != obj.getClass())
170+
}
171+
if (getClass() != obj.getClass()) {
169172
return false;
173+
}
170174
ProxyData other = (ProxyData) obj;
171-
if (dynamic != other.dynamic)
175+
if (dynamic != other.dynamic) {
172176
return false;
177+
}
173178
if (host == null) {
174-
if (other.host != null)
179+
if (other.host != null) {
175180
return false;
176-
} else if (!host.equals(other.host))
181+
}
182+
} else if (!host.equals(other.host)) {
177183
return false;
184+
}
178185
if (password == null) {
179-
if (other.password != null)
186+
if (other.password != null) {
180187
return false;
181-
} else if (!password.equals(other.password))
188+
}
189+
} else if (!password.equals(other.password)) {
182190
return false;
183-
if (port != other.port)
191+
}
192+
if (port != other.port) {
184193
return false;
185-
if (requiresAuthentication != other.requiresAuthentication)
194+
}
195+
if (requiresAuthentication != other.requiresAuthentication) {
186196
return false;
197+
}
187198
if (source == null) {
188-
if (other.source != null)
199+
if (other.source != null) {
189200
return false;
190-
} else if (!source.equals(other.source))
201+
}
202+
} else if (!source.equals(other.source)) {
191203
return false;
204+
}
192205
if (type == null) {
193-
if (other.type != null)
206+
if (other.type != null) {
194207
return false;
195-
} else if (!type.equals(other.type))
208+
}
209+
} else if (!type.equals(other.type)) {
196210
return false;
211+
}
197212
if (user == null) {
198-
if (other.user != null)
213+
if (other.user != null) {
199214
return false;
200-
} else if (!user.equals(other.user))
215+
}
216+
} else if (!user.equals(other.user)) {
201217
return false;
218+
}
202219
return true;
203220
}
204221

team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ private ProxyManager() {
8484
* @return the proxy manager
8585
*/
8686
public synchronized static IProxyService getProxyManager() {
87-
if (proxyManager == null)
87+
if (proxyManager == null) {
8888
proxyManager = new ProxyManager();
89+
}
8990
return proxyManager;
9091
}
9192

@@ -121,8 +122,9 @@ public synchronized String[] getNonProxiedHosts() {
121122
String prop = preferenceManager.getString(PreferenceManager.ROOT, PREF_NON_PROXIED_HOSTS);
122123
nonProxiedHosts = ProxyType.convertPropertyStringToHosts(prop);
123124
}
124-
if (nonProxiedHosts.length == 0)
125+
if (nonProxiedHosts.length == 0) {
125126
return nonProxiedHosts;
127+
}
126128
String[] result = new String[nonProxiedHosts.length];
127129
System.arraycopy(nonProxiedHosts, 0, result, 0, nonProxiedHosts.length );
128130
return result;
@@ -231,8 +233,9 @@ private boolean internalIsProxiesEnabled() {
231233
public void setProxiesEnabled(boolean enabled) {
232234
checkMigrated();
233235
boolean current = internalIsProxiesEnabled();
234-
if (current == enabled)
236+
if (current == enabled) {
235237
return;
238+
}
236239
// Setting the preference will trigger the system property update
237240
// (see preferenceChange)
238241
preferenceManager.putBoolean(PreferenceManager.ROOT, PREF_ENABLED, enabled);
@@ -300,13 +303,15 @@ public IProxyData[] getProxyDataForHost(String host) {
300303
return resolveType(nativeProxyProvider.select(uri));
301304
}
302305

303-
if (isHostFiltered(uri))
306+
if (isHostFiltered(uri)) {
304307
return new IProxyData[0];
308+
}
305309
IProxyData[] data = getProxyData();
306310
List<IProxyData> result = new ArrayList<>();
307311
for (IProxyData proxyData : data) {
308-
if (proxyData.getHost() != null)
312+
if (proxyData.getHost() != null) {
309313
result.add(proxyData);
314+
}
310315
}
311316
IProxyData ret[] = result.toArray(new IProxyData[result.size()]);
312317
return resolveType(ret);
@@ -329,8 +334,9 @@ private boolean isHostFiltered(URI uri) {
329334
if (host != null) {
330335
String[] filters = getNonProxiedHosts();
331336
for (String filter : filters) {
332-
if (StringUtil.hostMatchesFilter(host, filter))
337+
if (StringUtil.hostMatchesFilter(host, filter)) {
333338
return true;
339+
}
334340
}
335341
}
336342
return false;
@@ -342,20 +348,22 @@ public IProxyData getProxyDataForHost(String host, String type) {
342348
if (!internalIsProxiesEnabled()) {
343349
return null;
344350
}
345-
if (hasSystemProxies() && isSystemProxiesEnabled())
351+
if (hasSystemProxies() && isSystemProxiesEnabled()) {
346352
try {
347353
URI uri = new URI(type, "//" + host, null); //$NON-NLS-1$
348354
IProxyData[] proxyDatas = nativeProxyProvider.select(uri);
349355
return proxyDatas.length > 0 ? resolveType(proxyDatas[0]) : null;
350356
} catch (URISyntaxException e) {
351357
return null;
352358
}
359+
}
353360

354361
IProxyData[] data = getProxyDataForHost(host);
355362
for (IProxyData proxyData : data) {
356363
if (proxyData.getType().equalsIgnoreCase(type)
357-
&& proxyData.getHost() != null)
364+
&& proxyData.getHost() != null) {
358365
return resolveType(proxyData);
366+
}
359367
}
360368
return null;
361369
}
@@ -369,8 +377,9 @@ private void registerAuthenticator() {
369377

370378
private Authenticator getPluggedInAuthenticator() {
371379
IExtension[] extensions = RegistryFactory.getRegistry().getExtensionPoint(Activator.ID, Activator.PT_AUTHENTICATOR).getExtensions();
372-
if (extensions.length == 0)
380+
if (extensions.length == 0) {
373381
return null;
382+
}
374383
IExtension extension = extensions[0];
375384
IConfigurationElement[] configs = extension.getConfigurationElements();
376385
if (configs.length == 0) {
@@ -423,8 +432,9 @@ public boolean isSystemProxiesEnabled() {
423432
public void setSystemProxiesEnabled(boolean enabled) {
424433
checkMigrated();
425434
boolean current = isSystemProxiesEnabled();
426-
if (current == enabled)
435+
if (current == enabled) {
427436
return;
437+
}
428438
// Setting the preference will trigger the system property update
429439
// (see preferenceChange)
430440
preferenceManager.putBoolean(PreferenceManager.ROOT, PREF_OS, enabled);

0 commit comments

Comments
 (0)