Fix broken Java literalEval implementation in concoredocker.java#235
Fix broken Java literalEval implementation in concoredocker.java#235GaneshPatil7517 wants to merge 3 commits intoControlCore-Project:devfrom
Conversation
… Java execution path Fixes ControlCore-Project#228: concoredocker.java literalEval() was fundamentally broken. Changes to concoredocker.java: - Replace broken split-based literalEval/parseVal with recursive descent Parser that correctly handles nested structures, quoted strings with commas/colons, escape sequences, scientific notation, tuples, and trailing commas - Fix simtime type from int to double (preserves fractional values like 0.5) - Fix delay from 1ms to 1000ms (matches Python's time.sleep(1)) - Add maxRetries=5 to read() to prevent infinite blocking loops - Add Thread.currentThread().interrupt() in InterruptedException handlers - Add toPythonLiteral() serializer for write() (True/False/None format) - Fix write() to accept List in addition to Object[] - Fix initVal() to return List<Object> and use double simtime - Add error handling in parseFile() and defaultMaxTime() for malformed input - Add bounds check on sparams before charAt() New file TestLiteralEval.java: - 20 test methods (38 assertions) covering all parser functionality
There was a problem hiding this comment.
Pull request overview
Fixes the Java concoredocker Python-literal parsing/serialization used for file-based Docker IPC by replacing the previous split-based logic with a recursive-descent parser and aligning timing/retry behavior with the Python implementation.
Changes:
- Replaced
literalEval()with a recursive-descent parser supporting nested containers, strings/escapes, numbers (incl. scientific notation), booleans, andNone. - Updated IPC behavior:
delayto 1000ms,simtimetodouble, added bounded retries inread(), and added a Python-literal serializer forwrite(). - Added a Java test harness
TestLiteralEval.javato validate parser behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| concoredocker.java | Implements new literal parser, updates read/write semantics, simtime handling, retry logic, and serialization. |
| TestLiteralEval.java | Adds parser-focused regression tests for common and nested literal forms. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…th validation - requirements-ci.txt: add click, rich, psutil, beautifulsoup4, lxml (all imported by concore_cli which test_cli.py and test_graph.py depend on) - mkconcore.py: validate only basename in safe_name() so absolute paths passed by run.py are not rejected (/ was in forbidden charset)
|
Hey @pradeeban sir review this when you get the time... |
|
@GaneshPatil7517 Looks like you are changing the Python implementation also with this PR. I did not look carefully on what is changed in the python implementation. If those are some other important fixes, please create a separate PR for that. Pls keep this fixing Java a strictly java-only PR. That way, I can merge it without much consideration. |
Fixes #228
Problem:
concoredocker.javahas a fundamentally brokenliteralEval()that uses simpleString.split(',')— this fails on any input containing commas inside quoted strings, nested structures, or escape sequences. All Java-based Docker functionality is broken.Solution: Replace with a proper recursive descent parser and fix all related methods.
Changes to
concoredocker.java:literalEval()parser replacing the broken split-based implementation. Correctly handles:1.5e3)True/False) andNonesimtimechanged frominttodouble— preserves fractional values like0.5delaychanged from 1ms to 1000ms — matches Python'stime.sleep(1)maxRetries = 5added toread()— prevents infinite blocking (matches Python)Thread.currentThread().interrupt()in allInterruptedExceptionhandlerstoPythonLiteral()serializer forwrite()— outputsTrue/False/None(not Java'strue/false/null)write()acceptsListin addition to legacyObject[]initVal()returnsList<Object>with double simtimeparseFile()anddefaultMaxTime()for malformed inputsparamsbeforecharAt()New file
TestLiteralEval.java:Testing: