jtulach commented on code in PR #9635:
URL: https://github.com/apache/netbeans/pull/9635#discussion_r4084925426
##########
java/debugger.jpda/nbproject/org-netbeans-modules-debugger-jpda.sig:
##########
@@ -3013,19 +3014,19 @@ hfds methodName
CLSS public final org.netbeans.modules.debugger.jpda.models.ShortenedStrings
innr public static StringInfo
-meth public static
org.netbeans.modules.debugger.jpda.models.ShortenedStrings$StringInfo
getShortenedInfo(java.lang.String)
supr java.lang.Object
-hfds infoStrings,isLittleEndianCache,retrievingStrings,stringsCache
-hcls InternalStringEncoding,StringValueInfo
+hfds isLittleEndianCache,retrievingStrings,stringCache
+hcls InternalStringEncoding
CLSS public static
org.netbeans.modules.debugger.jpda.models.ShortenedStrings$StringInfo
outer org.netbeans.modules.debugger.jpda.models.ShortenedStrings
meth public int getLength()
-meth public int getShortLength()
+meth public int getShortendLength()
meth public java.io.Reader getContent()
meth public java.lang.String getFullString()
+meth public java.lang.String getShortendString()
Review Comment:
- must these methods appear in API changes list?
- I guess they have to as they are accessed from a different package
- and this package is listed as API
- can only one of the methods be added?
- seems to me `getShortenedString().length()` would be sufficient
##########
java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ShortenedStrings.java:
##########
@@ -469,8 +443,12 @@ private StringInfo(StringReference sr, int shortLength,
int length,
this.isLittleEndian = isLittleEndian;
}
- public int getShortLength() {
- return shortLength;
+ public String getShortendString() {
+ return this.shortendString;
+ }
+
+ public int getShortendLength() {
Review Comment:
I think this is a typo. It is "shortened" according to my dictionary.
##########
java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ShortenedStrings.java:
##########
@@ -313,9 +293,11 @@ else if (valuesField.type() instanceof ArrayType &&
}
String shortedString = new String(characters);
int stringLength = isUTF16 ? saLength / 2 : saLength;
- ShortenedStrings.register(shortedString, sr, stringLength, sa,
- backingEncoding, isLittleEndian);
- string = shortedString;
+ StringInfo si = new StringInfo(sr, shortedString,
stringLength, sa, backingEncoding, isLittleEndian);
+ synchronized (stringCache) {
+ stringCache.put(sr, si);
Review Comment:
- multiple threads can be running this `stringCache.put(sr, si)` code
- for the same `sr`, but different `si`
- that was also the old behavior, it is not changed by this PR
- I guess that doesn't matter
- at most the `StringInfo` is constructed multiple times in parallel
##########
java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/AbstractObjectVariable.java:
##########
@@ -511,7 +511,13 @@ static String getToStringValue (Value v, com.sun.jdi.Type
type, JPDADebuggerImpl
if (sr == null) {
return null;
}
- String str = ShortenedStrings.getStringWithLengthControl(sr);
+ Object stringData =
ShortenedStrings.getStringWithLengthControl(sr);
+ String str;
+ if(stringData instanceof ShortenedStrings.StringInfo si) {
Review Comment:
Missing space after `if`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists