- changed status to open
List<String> to String cast exception on URLUtils -> serializeParameters
This method worked in older versions but in the newer version you are trying to cast a List<String> to a String and this method bombs every time. Can we please fix this? Thanks!
for (Map.Entry<String,List<String>> entry: params.entrySet()) {
if (entry.getKey() == null || entry.getValue() == null)
continue;
// === problem is here
for (String value: entry.getValue()) {
if (value == null) {
value = "";
}
Comments (12)
-
-
Hi Craig,
Could you post a snippet or test that shows the bug?
We have a bunch of tests that pass this.
entry.getValue()
returns aList<String>
. I don't see a cast in this method. -
Added multivalued test: f3eaa55f
-
reporter Hi @vdzhuvinov
EntrySet returns a key, value. Your value is a List<String>. So when you do entry.getValue() you are returning a List<String>. However, you are trying to set the List<String> to a String in the inner for-loop. The cast is here...
for (String value: entry.getValue())
-
Hm, doesn't
entry.getValue()
resolve to List<String>?See the
Map.Entry<String,List<String>> entry
-
If you do see an exception, can you post its stack trace here?
-
- changed status to invalid
Bug not validated
-
reporter I don't understand how you aren't able to reproduce this. I've had 6 developers on my team have this identical issue.
The code doesn't even make sense. You are casting a List<String> to String. I think if you only have 1 String it may work, but with a real list of Strings, this will bomb every time.
-
There is no explicit cast in the method.
If code that calls the method does this cast - that's a different issue.
Can you post a stack trace of the cast exception?
-
for (String value: entry.getValue())
is essentially
List<String> someList = ....; for(String value: someList)
-
Here is a similar issue - arising from an incorrect call of the method:
(possibly the OAuth 2.0 SDK got updated in ADAL4j without recompiling the code / running tests)
-
reporter Yes that's exactly it. I had to roll this version back in Microsoft's oauth implementation for it to work.
- Log in to comment