Skip to content

Commit 5a8a7ed

Browse files
committed
Fix findbugs warnings
The serialize inner class cases are just suppressed for now.
1 parent 9937d1c commit 5a8a7ed

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

src/main/java/org/jvnet/hudson/plugins/port_allocator/GlassFishJmxPortType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@
2525
import java.rmi.UnmarshalException;
2626
import java.util.HashMap;
2727
import java.util.Map;
28+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2829

2930
/**
3031
* GlassFish JMX port so that runaway GF instance can be terminated.
3132
*
3233
* @author Kohsuke Kawaguchi
3334
*/
35+
@SuppressFBWarnings(value="SE_INNER_CLASS")
3436
public class GlassFishJmxPortType extends PortType {
3537
/**
3638
* GlassFish admin user name.
@@ -48,6 +50,7 @@ public GlassFishJmxPortType(String name, String userName, String password) {
4850
this.password = password;
4951
}
5052

53+
5154
@Override
5255
public Port allocate(Run<?, ?> run, final PortAllocationManager manager, int prefPort, final Launcher launcher, final TaskListener taskListener)
5356
throws IOException, InterruptedException
@@ -61,7 +64,7 @@ public Port allocate(Run<?, ?> run, final PortAllocationManager manager, int pre
6164
/**
6265
* Cleans up GlassFish instance.
6366
*/
64-
final class GlassFishCleanUpTask implements Callable<Void,IOException>, Serializable {
67+
class GlassFishCleanUpTask implements Callable<Void,IOException>, Serializable {
6568
private final TaskListener taskListener;
6669

6770
public GlassFishCleanUpTask(TaskListener taskListener) {

src/main/java/org/jvnet/hudson/plugins/port_allocator/PoolNotDefinedException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
/**
44
* @author pepov
55
*/
6-
public class PoolNotDefinedException extends Throwable {
6+
public class PoolNotDefinedException extends Exception {
77
}

src/main/java/org/jvnet/hudson/plugins/port_allocator/PortAllocationManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525

2626
public final class PortAllocationManager implements Serializable {
27-
private final Computer node;
27+
private transient final Computer node;
2828

2929
/** Maximum number of tries to allocate a specific port range. */
3030
private static final int MAX_TRIES = 100;
@@ -261,4 +261,6 @@ public Integer call() throws IOException {
261261
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
262262
}
263263
}
264+
265+
private static final long serialVersionUID = 1L;
264266
}

src/main/java/org/jvnet/hudson/plugins/port_allocator/PortAllocator.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class PortAllocator extends SimpleBuildWrapper
3838
{
3939
private static final Log log = LogFactory.getLog(PortAllocator.class);
4040

41-
public final List<PortType> ports = Lists.newArrayList();
41+
protected final List<PortType> ports = Lists.newArrayList();
4242

4343
private String pool;
4444
private final List<String> pools = Lists.newArrayList();
@@ -104,8 +104,9 @@ public void setUp(Context context, Run<?, ?> run, FilePath workspace, Launcher l
104104

105105
Computer cur = workspace.toComputer();
106106
Map<String,Integer> prefPortMap = new HashMap<String,Integer>();
107-
if (run.getPreviousBuild() != null) {
108-
AllocatedPortAction prevAlloc = run.getPreviousBuild().getAction(AllocatedPortAction.class);
107+
Run<?, ?> prevBuild = run.getPreviousBuild();
108+
if (prevBuild != null) {
109+
AllocatedPortAction prevAlloc = prevBuild.getAction(AllocatedPortAction.class);
109110
if (prevAlloc != null) {
110111
// try to assign ports assigned in previous build
111112
prefPortMap = prevAlloc.getPreviousAllocatedPorts();

src/main/java/org/jvnet/hudson/plugins/port_allocator/PortTypeDescriptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ protected PortTypeDescriptor(Class<? extends PortType> clazz) {
1919
/**
2020
* All registered {@link PortTypeDescriptor}s.
2121
*/
22-
public static final List<PortTypeDescriptor> LIST = new ArrayList<PortTypeDescriptor>();
22+
static final List<PortTypeDescriptor> LIST = new ArrayList<PortTypeDescriptor>();
2323
}

src/main/java/org/jvnet/hudson/plugins/port_allocator/TomcatShutdownPortType.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111

1212
import java.io.IOException;
1313
import java.io.Serializable;
14+
import java.nio.charset.StandardCharsets;
1415
import java.net.Socket;
16+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
17+
1518

1619
/**
1720
* Tomcat shutdown port.
1821
*
1922
* @author Kohsuke Kawaguchi
2023
*/
24+
@SuppressFBWarnings(value="SE_INNER_CLASS")
2125
public class TomcatShutdownPortType extends PortType {
2226
/**
2327
* Shutdown magic phrase.
@@ -57,7 +61,7 @@ public Void call() throws IOException {
5761
}
5862

5963
try {
60-
s.getOutputStream().write(password.getBytes());
64+
s.getOutputStream().write(password.getBytes(StandardCharsets.UTF_8));
6165
s.close();
6266
taskListener.getLogger().println("Shutdown left-over Tomcat");
6367
} catch (IOException x) {

0 commit comments

Comments
 (0)