Fix broken Java literalEval implementation in concoredocker#231
Open
GaneshPatil7517 wants to merge 2 commits intoControlCore-Project:mainfrom
Open
Fix broken Java literalEval implementation in concoredocker#231GaneshPatil7517 wants to merge 2 commits intoControlCore-Project:mainfrom
GaneshPatil7517 wants to merge 2 commits intoControlCore-Project:mainfrom
Conversation
The Java implementation of concoredocker was fundamentally broken.
literalEval() was implemented as a stub returning an empty HashMap,
causing read(), write(), defaultMaxTime(), and initVal() to silently
malfunction.
Changes:
- Implement proper Python-style literal parsing in literalEval()
- Supports dicts: {'key': value}
- Supports lists: [val1, val2]
- Supports numbers, strings, booleans, None
- Fix unchanged() to return boolean (was void)
- Fix defaultMaxTime() to read actual integer value
- Fix read() and write() to properly handle List types
- Add simtime tracking to match Python semantics
- Add TestLiteralEval.java with 15 test cases
Fixes ControlCore-Project#228
3f6b5c1 to
210a388
Compare
There was a problem hiding this comment.
Pull request overview
Fixes the Java concoredocker backend to actually parse Python-style literals (previously a stub), restoring correct behavior for reading ports, writing ports, and maxtime/simtime handling to better match the Python reference.
Changes:
- Implement a recursive-descent
literalEval()inconcoredocker.java(dict/list/number/string/bool/None). - Update
defaultMaxTime(),read(),write(),initVal(), andunchanged()to use the parsed literals and tracksimtime. - Add a standalone Java test driver
TestLiteralEval.javawith multiple parsing test cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
requirements.txt |
Adds pyzmq to match existing import zmq usage in the Python codebase. |
concoredocker.java |
Replaces no-op literal parsing with a real parser and updates I/O helpers to use it. |
TestLiteralEval.java |
Adds a basic test harness validating literalEval() behavior via reflection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Changes based on PR review: - Use double for simtime to preserve fractional values - Change delay from 1ms to 1000ms (matches Python's time.sleep(1)) - Add maxRetries limit in read() to avoid infinite blocking - Restore thread interrupt status in InterruptedException handlers - Catch RuntimeException in defaultMaxTime() for parse errors - Add try-catch in parseFileAsMap() with logging for malformed files - Wrap parseDouble/parseLong in try-catch with clear exceptions - Add toPythonLiteral() for proper serialization (True/False/None/strings) - Improve error messages throughout All changes align Java behavior with Python reference implementation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Java implementation of concoredocker was fundamentally broken.
literalEval()was implemented as a no-op returning an empty HashMap,causing
read(),write(),defaultMaxTime(), andinitVal()to silently malfunction.Fix
literalEval(){'key': value}[val1, val2]unchanged()to return boolean (was void)defaultMaxTime()to read actual integer valueread()andwrite()to properly handle List typessimtimetracking to match Python semanticsImpact
Fixes #228