-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Naive implementation of UpgradeProtocol #38
base: jtango-9-lts
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see the general idea. I think we need to discuss message format and payload format more. For now it still tied to CORBA serialization strategy.
// ========================================================================== | ||
|
||
public double readAttributeDouble(String name) throws DevFailed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lacking documentation
try { | ||
TangoMessage<Double> message = new TangoMessage<>("read", this.get_name(), name, TangoConst.Tango_DEV_DOUBLE, 0D); | ||
|
||
message = marshaller.unmarshal(transport.send(marshaller.marshal(message))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug log entry here?
@@ -2020,6 +2080,10 @@ private static void checkDuplication(String[] list, String orig) throws DevFaile | |||
*/ | |||
//========================================================================== | |||
protected void finalize() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finalize is deprecated in Java 9 and is discouraged even before. Should use AutoCloseable
and implement close
mrthod.
import java.util.stream.Collectors; | ||
|
||
/** | ||
* @author Igor Khokhriakov <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short documentation required
|
||
import com.google.common.collect.Collections2; | ||
import com.google.common.collect.Iterables; | ||
import com.google.common.collect.Lists; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest remove Guava if possible. Using mix of Guava and Java 8 is confusing. Most Guava functions have analogues in Java 8.
|
||
@Override | ||
public TangoMessage unmarshal(InputStream stream) { | ||
return gson.fromJson(new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)), TangoMessage.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential bug here. If there are subsequent reads from the same stream, BufferedReader will read its buffer size and the next reader will start in the wrong place. If the stream is exhausted after read, it should be closed.
|
||
@Override | ||
public TangoMessage unmarshal(InputStream stream) { | ||
BufferedReader br = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as above
public String device; | ||
public String target; | ||
public int dataType; | ||
public T value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No serialization strategy here. I really do not like using toString
for something other than debug. There should be either additional decoder/encoder strategy or limits on T
.
} | ||
|
||
@Override | ||
public void connect(String endpoint) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging here? Also there probably should be a check about connecting, when connection already exists.
@altavir thanks a lot for your input! |
More to think about: