Skip to content

CASL-1785: fix HttpStorageProperties bug#575

Merged
Marcin-Here merged 2 commits intov3from
CASL-1785_fix_httpStorageProperties
Apr 30, 2026
Merged

CASL-1785: fix HttpStorageProperties bug#575
Marcin-Here merged 2 commits intov3from
CASL-1785_fix_httpStorageProperties

Conversation

@Marcin-Here
Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Marcin-Here <ext-marcin.grabowski@here.com>
@github-actions
Copy link
Copy Markdown

Code Coverage

Overall Project 62.91% -0.01% 🍏
Files changed 92.37% 🍏

File Coverage
RequestSender.java 82.3% 🍏
HttpStorageProperties.java 78.57% -4.29% 🍏
HttpStorage.java 49.7% 🍏

if (raw instanceof HeaderMap) {
return (HeaderMap) raw;
}
if (raw instanceof Map<?, ?>) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IntelliJ complains that it is always false. Meaning, it will never to Map<?, ?> . Which seems true. Pls revisit and remove this condition if not needed.
In that case, the earlier check of raw instanceof HeaderMap is also not needed. It will either be null or of type HeaderMap, so just checking for null should be sufficient?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Personally, I vote for keep these checks. The Kotlin Multiplatform build is not the most straightforward when it comes to IDE errors/warnings as I have seen.
In this case for example I can wrongly do setRaw(HEADERS, "12"); somewhere, and that string would still be stored. So correcting the headers here at getter looks to be the only solution without interfering with the underlying MapProxy (ideally I prefer to somehow catch this right when it was set).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The way I am thinking, creates a doubt - if there is a possibility where setRaw(HEADERS, "12"); can happen during runtime? In the code, I don't see such case. Help with one example?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One example would be new HttpStorageProperties().setRaw(<<any Object>>), by mistake somewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think you both are correct. with setRaw() and getRaw() we lose encapsulation but it's design of proxy model. Also Map check looks like a lot of boilerplate, and in normal flow it would be unnecessary, also Intelij is sometimes confused by proxy model. What is happening in that case: In most used flow in Storage, Handler etc jsons. When we want access properties we use JvmBoxingUtil.box(eventHandlerConfig.getProperties(), DefaultStorageHandlerProperties.class)); and in our case HttpStorageProperties storageProperties = JvmBoxingUtil.box(storage.getProperties(), HttpStorageProperties.class); Now when properties has nested objects like in our case Map. In boxing process it's become AnyObject by proxy model. In normal use case we then just call gets on our properties, if we don't have Map<?,?> check in get. It would fail HeaderMap check and create and return default headers, so we need step to translate our AnyObject to our wrapper in this case HeaderMap extends JvmMapProxy<String, String> . I personally think and from I remember Kuba agreed, that proxy model it's a bit complicated and confusing to use for new users, also creating what normally would be POJO becomes complicated and time consuming tasks, like in this example of which we're talking right now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also added test shouldPreserveHeadersWhenBoxingStoragePropertiesFromJson to help understand what is going on.


public void setProtocol(final HttpInterface protocol) {setRaw(HTTP_INTERFACE, protocol);}

private @NotNull HeaderMap toHeaderMap(@NotNull Map<?, ?> rawHeaders) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the earlier comment about "Map<? , ?> not being used" is accepted, then this function also can be removed?

Comment thread gradle.properties

# When updating the version, please consider:
# automatically updated:
# here-naksha-lib-core/NakshaVersion (static property: latest)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think NakshaVersion also needs to be updated with new version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Signed-off-by: Marcin-Here <ext-marcin.grabowski@here.com>
@github-actions
Copy link
Copy Markdown

Code Coverage

Overall Project 62.94% -0.01% 🍏
Files changed 92.37% 🍏

File Coverage
NakshaVersion.kt 84.98% 🍏
RequestSender.java 82.3% 🍏
HttpStorageProperties.java 78.57% -4.29% 🍏
HttpStorage.java 49.7% 🍏

@Marcin-Here Marcin-Here merged commit 0290ea2 into v3 Apr 30, 2026
3 checks passed
@Marcin-Here Marcin-Here deleted the CASL-1785_fix_httpStorageProperties branch April 30, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants