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

Remove package cycles involving lease, internal, exception, and frame #774

Merged
merged 4 commits into from
Apr 11, 2020

Conversation

rstoyanchev
Copy link
Contributor

@rstoyanchev rstoyanchev commented Apr 9, 2020

This resolves package cycles between:

  • lease - internal due to ClientSetup and ServerSetup (both related to leasing).
  • exception - lease due to references between MissingLeaseException and Lease.
  • exception - frame due to references between ErrorFrameFlyweight and RSocketException.

This is mostly backwards compatible and functionality neutral except for moving MissingLeasingException to lease. It's unlikely to break anything and a worthwhile trade-off.

Move ClientSetup and ServerSetup are closely associated with the
RSocketFactory implementations. Moving them into core where they are
used from breaks a package cycle between resume and internal.

ClientSetup is straight-forward and folds easily into
DefaultClientRSocketFactory.

ConnectionUtil is closely associated with ServerSetup and has been
folded into it.

Signed-off-by: Rossen Stoyanchev <rstoyanchev@pivotal.io>
@OlegDokuka OlegDokuka added breaking changes Changes that break API or behaviour enhancement labels Apr 10, 2020
@OlegDokuka OlegDokuka added refactorings Changes that does not affect API and behaviour and removed breaking changes Changes that break API or behaviour enhancement labels Apr 10, 2020
MissingLeaseException is moved to the lease package next to the
contracts it is declared in breaking a cycle between lease and
exceptions. This is an API breakage but I the impact should be
minor (none? the chances of something handling it explicitly) and
hence an acceptable trade-off.

Signed-off-by: Rossen Stoyanchev <rstoyanchev@pivotal.io>
Replaces (now deprecated) RSocketException from the exceptions package
which can lead to cycles (e.g. with frame package).

Other minor refinements:

- error code validation
- shared errorCode() implementation
- error code in toString()
- avoid NPE for null message, it's better to keep the original exception
  and null is allowed by getMessage().

Signed-off-by: Rossen Stoyanchev <rstoyanchev@pivotal.io>
*/
public RSocketException(String message, @Nullable Throwable cause) {
super(Objects.requireNonNull(message, "message must not be null"), cause);
super(0x00000201, message, cause);
Copy link
Member

Choose a reason for hiding this comment

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

can we use ErrorType.APPLICATION_ERROR here. In any case, we have ref to ErrorType

Suggested change
super(0x00000201, message, cause);
super(ErrorType.APPLICATION_ERROR, message, cause);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, indeed, this should be a constant. I've suggested a further change to use the constants from ErrorFrameFlyweight.

@@ -16,41 +16,47 @@

package io.rsocket.exceptions;

import java.util.Objects;
import io.rsocket.RSocketErrorException;
import reactor.util.annotation.Nullable;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import reactor.util.annotation.Nullable;
import io.rsocket.frame.ErrorType;
import reactor.util.annotation.Nullable;

Copy link
Member

@OlegDokuka OlegDokuka left a comment

Choose a reason for hiding this comment

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

In general LGTM. Just a single minor proposal to use constant

This change deprecates ErrorType as the same constants are already
declared in ErrorFrameFlyweight and there is hierarchy of exceptions
with one exception per error code.

Signed-off-by: Rossen Stoyanchev <rstoyanchev@pivotal.io>
@OlegDokuka OlegDokuka changed the title Remove more package cycles reduce package cycles Apr 11, 2020
@OlegDokuka OlegDokuka merged commit a9c385a into rsocket:develop Apr 11, 2020
@rstoyanchev rstoyanchev deleted the package-cycles branch April 11, 2020 13:09
@rstoyanchev rstoyanchev modified the milestones: 1.0, 1.0.0-RC7 Apr 17, 2020
@rstoyanchev rstoyanchev changed the title reduce package cycles Remove package cycles involving lease, internal, exception, and frame Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactorings Changes that does not affect API and behaviour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants