Skip to content

Commit 424f835

Browse files
mint-runsmint-runs
authored andcommitted
update InputStreamThread.java
1 parent 4c4bb34 commit 424f835

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

src/main/java/de/javasocketapi/core/InputStreamThread.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,19 @@ class InputStreamThread {
1313

1414
private final Client client;
1515
private final Socket socket;
16-
private final Timer timer;
17-
18-
{
19-
this.timer = new Timer();
20-
}
16+
private final Timer timer = new Timer();
2117

2218
public InputStreamThread(final Client client) {
2319
this.client = client;
2420
this.socket = this.client.getSocket();
2521
}
2622

27-
public void run() {
23+
public void run() throws IOException {
2824
//initialise inputStream
29-
InputStream inputStream = null;
30-
try {
31-
inputStream = this.socket.getInputStream();
32-
} catch (final IOException e) {
33-
e.printStackTrace();
34-
}
25+
final InputStream finalInputStream = this.socket.getInputStream();
26+
3527
final AtomicReference<byte[]> bytes = new AtomicReference<>(null);
3628
//start reading byte arrays
37-
final InputStream finalInputStream = inputStream;
3829
this.timer.scheduleAtFixedRate(new TimerTask() {
3930
@Override
4031
public void run() {
@@ -75,9 +66,9 @@ public void run() {
7566
InputStreamThread.this.socket.close();
7667
}
7768
}
78-
} catch (final InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
79-
e.printStackTrace();
80-
} catch (final IOException e) {
69+
} catch (final InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException exception) {
70+
exception.printStackTrace();
71+
} catch (final IOException ignored) {
8172
InputStreamThread.this.interrupt();
8273
}
8374
}

0 commit comments

Comments
 (0)