Skip to content

Commit

Permalink
refactor(language-web): stricted limits
Browse files Browse the repository at this point in the history
  • Loading branch information
kris7t committed Jan 15, 2025
1 parent a4bd03d commit d951211
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

public class ModelGenerationWorker implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(ModelGenerationWorker.class);
private static final int MAX_SERIALIZED_MODEL_SIZE = 200;

private final UUID uuid = UUID.randomUUID();

Expand Down Expand Up @@ -155,11 +156,15 @@ public ModelGenerationResult doRun() throws IOException {
cancellationToken.checkCancelled();
var partialInterpretation = partialInterpretation2Json.getPartialInterpretation(generator, cancellationToken);
String source;
try {
source = serializeSolution(generator);
} catch (IOException e) {
LOG.error("Error while serializing generated model", e);
return new ModelGenerationErrorResult(uuid, "Failed to save solution: " + e.getMessage());
if (nodesMetadata.list().size() <= MAX_SERIALIZED_MODEL_SIZE) {
try {
source = serializeSolution(generator);
} catch (IOException e) {
LOG.error("Error while serializing generated model", e);
return new ModelGenerationErrorResult(uuid, "Failed to save solution: " + e.getMessage());
}
} else {
source = null;
}
return new ModelGenerationSuccessResult(uuid, nodesMetadata.list(), relationsMetadata, partialInterpretation,
source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public XtextWebSocket(ISession session, IResourceServiceProvider.Registry resour

@OnWebSocketOpen
public void onOpen(Session webSocketSession) {
webSocketSession.setMaxOutgoingFrames(10);
if (this.webSocketSession != null) {
LOG.error("Websocket session onConnect when already connected");
return;
Expand Down

0 comments on commit d951211

Please sign in to comment.