Skip to content

Commit f1411b4

Browse files
committed
Formatted
1 parent bf2279c commit f1411b4

File tree

3 files changed

+62
-67
lines changed

3 files changed

+62
-67
lines changed

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/workflow/action/DeepCopyBufferedMessagesAction.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,29 @@ public boolean executedAsPlanned() {
4242
public void reset() {
4343
setExecuted(false);
4444
}
45-
46-
private void deepCopyMessages(TlsContext src, TlsContext dst)
47-
{
48-
LinkedList<ProtocolMessage> messageBuffer = new LinkedList<>();
45+
46+
private void deepCopyMessages(TlsContext src, TlsContext dst) {
47+
LinkedList<ProtocolMessage> messageBuffer = new LinkedList<>();
4948
ObjectOutputStream outStream;
5049
ObjectInputStream inStream;
5150
try {
5251
for (ProtocolMessage message : src.getMessageBuffer()) {
53-
54-
ByteArrayOutputStream stream = new ByteArrayOutputStream();
55-
outStream = new ObjectOutputStream(stream);
56-
outStream.writeObject(message);
57-
outStream.close();
58-
inStream = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray()));
59-
ProtocolMessage messageCopy = (ProtocolMessage) inStream.readObject();
6052

61-
messageBuffer.add(messageCopy);
62-
}
53+
ByteArrayOutputStream stream = new ByteArrayOutputStream();
54+
outStream = new ObjectOutputStream(stream);
55+
outStream.writeObject(message);
56+
outStream.close();
57+
inStream = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray()));
58+
ProtocolMessage messageCopy = (ProtocolMessage) inStream.readObject();
59+
60+
messageBuffer.add(messageCopy);
61+
}
6362
} catch (IOException | ClassNotFoundException ex) {
64-
LOGGER.error("Error while creating deep copy of messageBuffer");
65-
throw new WorkflowExecutionException(ex.toString());
63+
LOGGER.error("Error while creating deep copy of messageBuffer");
64+
throw new WorkflowExecutionException(ex.toString());
6665
}
67-
68-
dst.setMessageBuffer(messageBuffer);
66+
67+
dst.setMessageBuffer(messageBuffer);
6968
}
7069

7170
}

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/workflow/action/DeepCopyBufferedRecordsAction.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,28 @@ public boolean executedAsPlanned() {
4343
public void reset() {
4444
setExecuted(false);
4545
}
46-
47-
private void deepCopyRecords(TlsContext src, TlsContext dst)
48-
{
46+
47+
private void deepCopyRecords(TlsContext src, TlsContext dst) {
4948
LinkedList<AbstractRecord> recordBuffer = new LinkedList<>();
5049
ObjectOutputStream outStream;
5150
ObjectInputStream inStream;
5251
try {
5352
for (AbstractRecord record : src.getRecordBuffer()) {
54-
55-
ByteArrayOutputStream stream = new ByteArrayOutputStream();
56-
outStream = new ObjectOutputStream(stream);
57-
outStream.writeObject(record);
58-
outStream.close();
59-
inStream = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray()));
60-
AbstractRecord recordCopy = (AbstractRecord) inStream.readObject();
6153

62-
recordBuffer.add(recordCopy);
63-
}
54+
ByteArrayOutputStream stream = new ByteArrayOutputStream();
55+
outStream = new ObjectOutputStream(stream);
56+
outStream.writeObject(record);
57+
outStream.close();
58+
inStream = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray()));
59+
AbstractRecord recordCopy = (AbstractRecord) inStream.readObject();
60+
61+
recordBuffer.add(recordCopy);
62+
}
6463
} catch (IOException | ClassNotFoundException ex) {
65-
LOGGER.error("Error while creating deep copy of recordBuffer");
66-
throw new WorkflowExecutionException(ex.toString());
64+
LOGGER.error("Error while creating deep copy of recordBuffer");
65+
throw new WorkflowExecutionException(ex.toString());
6766
}
68-
67+
6968
dst.setRecordBuffer(recordBuffer);
7069
}
7170

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/workflow/action/DeepCopyBuffersAction.java

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,56 +44,53 @@ public boolean executedAsPlanned() {
4444
public void reset() {
4545
setExecuted(false);
4646
}
47-
48-
private void deepCopyRecords(TlsContext src, TlsContext dst)
49-
{
47+
48+
private void deepCopyRecords(TlsContext src, TlsContext dst) {
5049
LinkedList<AbstractRecord> recordBuffer = new LinkedList<>();
5150
ObjectOutputStream outStream;
5251
ObjectInputStream inStream;
5352
try {
5453
for (AbstractRecord record : src.getRecordBuffer()) {
55-
56-
ByteArrayOutputStream stream = new ByteArrayOutputStream();
57-
outStream = new ObjectOutputStream(stream);
58-
outStream.writeObject(record);
59-
outStream.close();
60-
inStream = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray()));
61-
AbstractRecord recordCopy = (AbstractRecord) inStream.readObject();
62-
63-
recordBuffer.add(recordCopy);
64-
}
54+
55+
ByteArrayOutputStream stream = new ByteArrayOutputStream();
56+
outStream = new ObjectOutputStream(stream);
57+
outStream.writeObject(record);
58+
outStream.close();
59+
inStream = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray()));
60+
AbstractRecord recordCopy = (AbstractRecord) inStream.readObject();
61+
62+
recordBuffer.add(recordCopy);
63+
}
6564
} catch (IOException | ClassNotFoundException ex) {
66-
LOGGER.error("Error while creating deep copy of recordBuffer");
67-
throw new WorkflowExecutionException(ex.toString());
65+
LOGGER.error("Error while creating deep copy of recordBuffer");
66+
throw new WorkflowExecutionException(ex.toString());
6867
}
69-
68+
7069
dst.setRecordBuffer(recordBuffer);
7170
}
72-
73-
private void deepCopyMessages(TlsContext src, TlsContext dst)
74-
{
75-
LinkedList<ProtocolMessage> messageBuffer = new LinkedList<>();
71+
72+
private void deepCopyMessages(TlsContext src, TlsContext dst) {
73+
LinkedList<ProtocolMessage> messageBuffer = new LinkedList<>();
7674
ObjectOutputStream outStream;
7775
ObjectInputStream inStream;
7876
try {
7977
for (ProtocolMessage message : src.getMessageBuffer()) {
80-
81-
ByteArrayOutputStream stream = new ByteArrayOutputStream();
82-
outStream = new ObjectOutputStream(stream);
83-
outStream.writeObject(message);
84-
outStream.close();
85-
inStream = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray()));
86-
ProtocolMessage messageCopy = (ProtocolMessage) inStream.readObject();
87-
88-
messageBuffer.add(messageCopy);
89-
}
78+
79+
ByteArrayOutputStream stream = new ByteArrayOutputStream();
80+
outStream = new ObjectOutputStream(stream);
81+
outStream.writeObject(message);
82+
outStream.close();
83+
inStream = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray()));
84+
ProtocolMessage messageCopy = (ProtocolMessage) inStream.readObject();
85+
86+
messageBuffer.add(messageCopy);
87+
}
9088
} catch (IOException | ClassNotFoundException ex) {
91-
LOGGER.error("Error while creating deep copy of messageBuffer");
92-
throw new WorkflowExecutionException(ex.toString());
89+
LOGGER.error("Error while creating deep copy of messageBuffer");
90+
throw new WorkflowExecutionException(ex.toString());
9391
}
94-
95-
dst.setMessageBuffer(messageBuffer);
92+
93+
dst.setMessageBuffer(messageBuffer);
9694
}
97-
9895

9996
}

0 commit comments

Comments
 (0)