Skip to content
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

fix(java): Set the default maximum value for XdrString. #159

Merged
merged 5 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/xdrgen/generators/java.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

module Xdrgen
module Generators

class Java < Xdrgen::Generators::Base

def generate
Expand Down Expand Up @@ -834,7 +833,7 @@ def decode_type(decl)
when AST::Typespecs::Bool ;
"stream.readInt() == 1 ? true : false"
when AST::Typespecs::String ;
"XdrString.decode(stream, #{decl.size})"
"XdrString.decode(stream, #{decl.size || 'Integer.MAX_VALUE'})"
when AST::Typespecs::Simple ;
"#{name decl.type.resolved_type}.decode(stream)"
when AST::Concerns::NestedDefinition ;
Expand Down
2 changes: 1 addition & 1 deletion spec/output/generator_spec_java/struct.x/MyStruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static MyStruct decode(XdrDataInputStream stream) throws IOException {
int someOpaquesize = 10;
decodedMyStruct.someOpaque = new byte[someOpaquesize];
stream.read(decodedMyStruct.someOpaque, 0, someOpaquesize);
decodedMyStruct.someString = XdrString.decode(stream, );
decodedMyStruct.someString = XdrString.decode(stream, Integer.MAX_VALUE);
decodedMyStruct.maxString = XdrString.decode(stream, 100);
return decodedMyStruct;
}
Expand Down
2 changes: 1 addition & 1 deletion spec/output/generator_spec_java/test.x/Str2.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void encode(XdrDataOutputStream stream) throws IOException {
}
public static Str2 decode(XdrDataInputStream stream) throws IOException {
Str2 decodedStr2 = new Str2();
decodedStr2.str2 = XdrString.decode(stream, );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code fails to compile.

decodedStr2.str2 = XdrString.decode(stream, Integer.MAX_VALUE);
return decodedStr2;
}

Expand Down