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

Java - URISyntaxException size reduction opportunity #3149

Closed
baywet opened this issue Aug 15, 2023 · 2 comments · Fixed by #3162
Closed

Java - URISyntaxException size reduction opportunity #3149

baywet opened this issue Aug 15, 2023 · 2 comments · Fixed by #3162
Assignees
Labels
enhancement New feature or request Java WIP
Milestone

Comments

@baywet
Copy link
Member

baywet commented Aug 15, 2023

more details here

This exception might have been thrown before we used URI templates when we were building the URI in an "ad-hoc" way. It's not needed anymore.

We should update the generation of request executor method from

    @jakarta.annotation.Nonnull
    public java.util.concurrent.CompletableFuture<User> get() {
        try {
            final RequestInformation requestInfo = toGetRequestInformation(null);
            final HashMap<String, ParsableFactory<? extends Parsable>> errorMapping = new HashMap<String, ParsableFactory<? extends Parsable>>();
            errorMapping.put("4XX", ODataError::createFromDiscriminatorValue);
            errorMapping.put("5XX", ODataError::createFromDiscriminatorValue);
            return this.requestAdapter.sendAsync(requestInfo, User::createFromDiscriminatorValue, errorMapping);
        } catch (URISyntaxException ex) {
            final java.util.concurrent.CompletableFuture<User> executionException = new java.util.concurrent.CompletableFuture<User>();
            executionException.completeExceptionally(ex);
            return executionException;
        }
    }

to

    @jakarta.annotation.Nonnull
    public java.util.concurrent.CompletableFuture<User> get() {
        final RequestInformation requestInfo = toGetRequestInformation(null);
        final HashMap<String, ParsableFactory<? extends Parsable>> errorMapping = new HashMap<String, ParsableFactory<? extends Parsable>>();
        errorMapping.put("4XX", ODataError::createFromDiscriminatorValue);
        errorMapping.put("5XX", ODataError::createFromDiscriminatorValue);
        return this.requestAdapter.sendAsync(requestInfo, User::createFromDiscriminatorValue, errorMapping);
    }

And to remove the exception throws declaration from generator methods.
We should also remove the code using inserted by the refiner.

This should significantly reduce the resulting size of the client

@baywet baywet added enhancement New feature or request Java labels Aug 15, 2023
@baywet baywet added this to the Kiota v1.6 milestone Aug 15, 2023
@baywet baywet added this to Kiota Aug 15, 2023
@github-project-automation github-project-automation bot moved this to Todo in Kiota Aug 15, 2023
@ramsessanchez
Copy link
Contributor

Hi @baywet , Could you clarify what you mean by "remove the code using inserted by the refiner"?

@baywet
Copy link
Member Author

baywet commented Aug 15, 2023

This

new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Java WIP
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants