Skip to content

Commit

Permalink
Fix most warnings in e4-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Aug 1, 2024
1 parent 0c5461a commit 6a14115
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 53 deletions.
14 changes: 0 additions & 14 deletions e4tools/bundles/org.eclipse.e4.tools.emf.ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,4 @@
<skipAPIAnalysis>true</skipAPIAnalysis> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=548572 -->
</properties>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-warn:-raw,unchecked</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.List;
import java.util.Locale;
import java.util.PropertyResourceBundle;
Expand Down Expand Up @@ -248,7 +245,6 @@ class ProjectResourceBundleControl extends ResourceBundle.Control {
this.useFallback = useFallback;
}

@SuppressWarnings("resource")
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader,
boolean reload) throws IllegalAccessException, InstantiationException, IOException {
Expand All @@ -257,18 +253,8 @@ public ResourceBundle newBundle(String baseName, Locale locale, String format, C
ResourceBundle bundle = null;
if (format.equals("java.properties")) { //$NON-NLS-1$
final String resourceName = toResourceName(bundleName, "properties"); //$NON-NLS-1$
InputStream stream = null;
try {
stream = AccessController.doPrivileged((PrivilegedExceptionAction<InputStream>) () -> getResourceAsStream(resourceName));
} catch (final PrivilegedActionException e) {
throw (IOException) e.getException();
}
if (stream != null) {
try {
bundle = new PropertyResourceBundle(stream);
} finally {
stream.close();
}
try (InputStream stream = getResourceAsStream(resourceName);) {
bundle = new PropertyResourceBundle(stream);
}
} else {
throw new IllegalArgumentException("unknown format: " + format); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.eclipse.jdt.internal.ui.text.java.AbstractTemplateCompletionProposalComputer;
import org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateEngine;
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
import org.eclipse.jface.text.templates.ContextTypeRegistry;
import org.eclipse.jface.text.templates.TemplateContextType;
import org.eclipse.text.templates.ContextTypeRegistry;

/**
* Computer that computes the template proposals for the E4 context type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.List;
import java.util.Locale;
import java.util.MissingResourceException;
Expand Down Expand Up @@ -396,28 +393,21 @@ public ResourceBundle newBundle(String baseName, Locale locale,
ResourceBundle bundle = null;
if (format.equals("java.properties")) { //$NON-NLS-1$
final String resourceName = toResourceName(bundleName, "properties"); //$NON-NLS-1$
PrivilegedExceptionAction<InputStream> action = (PrivilegedExceptionAction<InputStream>) () -> {
URL url = osgiBundle.getEntry(resourceName);
if (url != null) {
URLConnection connection = url.openConnection();
if (connection != null) {
// Disable caches to get fresh data for
// reloading.
connection.setUseCaches(false);
return connection.getInputStream();
URL url = osgiBundle.getEntry(resourceName);
if (url != null) {
URLConnection connection = url.openConnection();
if (connection != null) {
// Disable caches to get fresh data for
// reloading.
connection.setUseCaches(false);
try (InputStream stream = connection.getInputStream()) {
if (stream != null) {
bundle = new PropertyResourceBundle(stream);
}
}
}
return null;
};
try (InputStream stream = AccessController.doPrivileged(action)) {
if (stream != null) {
bundle = new PropertyResourceBundle(stream);
}
} catch (final PrivilegedActionException e) {
throw (IOException) e.getException();
}
}
else {
} else {
throw new IllegalArgumentException("unknown format: " + format); //$NON-NLS-1$
}
return bundle;
Expand Down

0 comments on commit 6a14115

Please sign in to comment.