Commit ca000eee authored by Lubomir Bulej's avatar Lubomir Bulej

Avoid using the now non-existent ByteArrayUtils in legacy shvm-server

parent f44242c4
Pipeline #6744 failed with stages
in 4 minutes and 28 seconds
package ch.usi.dag.reserver;
import ch.usi.dag.dislre.protocol.Main.*;
import ch.usi.dag.dislre.protocol.Analysis.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import ch.usi.dag.dislre.protocol.Analysis.Analyze;
import ch.usi.dag.dislre.protocol.Analysis.ClassInfo;
import ch.usi.dag.dislre.protocol.Analysis.NewClass;
import ch.usi.dag.dislre.protocol.Analysis.ObjectFree;
import ch.usi.dag.dislre.protocol.Analysis.RegisterAnalysis;
import ch.usi.dag.dislre.protocol.Analysis.StringInfo;
import ch.usi.dag.dislre.protocol.Analysis.ThreadInfo;
import ch.usi.dag.dislre.protocol.Main.ClientMessage;
import ch.usi.dag.shvm.DiSLREServerException;
import ch.usi.dag.shvm.SHVM;
import ch.usi.dag.util.logging.Logger;
import ch.usi.dag.util.ByteArrayUtils;
/**
......@@ -31,18 +39,18 @@ final class RequestDispatcher {
switch (clientMessage.getRequestCase ())
{
case ANALYZE:
Analyze analyze = clientMessage.getAnalyze ();
final Analyze analyze = clientMessage.getAnalyze ();
shadowVM.HandleAnalyze (
analyze.getOrderingID (),
analyze.getInvocationCount (),
analyze.getRawData ().toByteArray ()
analyze.getRawData ().asReadOnlyByteBuffer ()
);
break;
case CLOSE_CONNECTION:
shadowVM.HandleClose ();
break;
case CLASS_INFO:
ClassInfo classInfo = clientMessage.getClassInfo ();
final ClassInfo classInfo = clientMessage.getClassInfo ();
shadowVM.HandleClassInfo (
classInfo.getClassTag (),
classInfo.getClassSignature (),
......@@ -52,7 +60,7 @@ final class RequestDispatcher {
);
break;
case NEW_CLASS:
NewClass newClass = clientMessage.getNewClass ();
final NewClass newClass = clientMessage.getNewClass ();
shadowVM.HandleNewClass (
newClass.getClassName (),
newClass.getClassLoaderTag (),
......@@ -63,21 +71,21 @@ final class RequestDispatcher {
shadowVM.HandleThreadEnd (clientMessage.getThreadEnd ().getThreadId ());
break;
case REGISTER_ANALYSIS:
RegisterAnalysis registerAnalysis = clientMessage.getRegisterAnalysis ();
final RegisterAnalysis registerAnalysis = clientMessage.getRegisterAnalysis ();
shadowVM.HandleRegisterAnalysis (
registerAnalysis.getAnalysisId (),
registerAnalysis.getDescriptor ()
);
break;
case STRING_INFO:
StringInfo stringInfo = clientMessage.getStringInfo ();
final StringInfo stringInfo = clientMessage.getStringInfo ();
shadowVM.HandleStringInfo (
stringInfo.getStringTag (),
stringInfo.getStringData ()
);
break;
case THREAD_INFO:
ThreadInfo threadInfo = clientMessage.getThreadInfo ();
final ThreadInfo threadInfo = clientMessage.getThreadInfo ();
shadowVM.HandleThreadInfo (
threadInfo.getThreadTag (),
threadInfo.getName (),
......@@ -85,19 +93,13 @@ final class RequestDispatcher {
);
break;
case OBJECT_FREE:
int count = clientMessage.getObjectFree().getCount ();
long[] ids = new long[count];
byte[] byteArray = clientMessage.getObjectFree ().getRawData ().toByteArray ();
logger.error (
"Serious error in data transfer: Indicated length (%d) does not match real length (%d)",
count, byteArray.length);
final ObjectFree objectFree = clientMessage.getObjectFree ();
// ByteArrayUtils method used here, since it's much more lightweight solution than
// creating an input stream again.
for (int i = 0; i < count; ++i) {
ids[i] = ByteArrayUtils.ReadLong (byteArray, i * Long.BYTES);
}
final long [] ids = new long [objectFree.getCount ()];
ByteBuffer.wrap (objectFree.toByteArray ())
.order (ByteOrder.BIG_ENDIAN)
.asLongBuffer ()
.get (ids);
shadowVM.HandleObjectFree (ids);
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment