eclipse-californium / californium

CoAP/DTLS Java Implementation
https://www.eclipse.org/californium/
Other
730 stars 367 forks source link

`nonPublicPartOfAPI` for `EpochMessage` reported by revapi #2259

Open sbernard31 opened 4 months ago

sbernard31 commented 4 months ago

When building leshan, revapi reports something wrong with californium API. (I think this is not new but before I just ignored all error from californium and I changed my build config about that recently)

Report :

{
  "ignore": true,
  "code": "java.class.nonPublicPartOfAPI",
  "new": "class org.eclipse.californium.scandium.dtls.DTLSFlight.EpochMessage",
  "justification": "ADD YOUR EXPLANATION FOR THE NECESSITY OF THIS CHANGE"
    "classSimpleName": "EpochMessage",
  "exampleUseChainInNewApi": "org.eclipse.californium.scandium.dtls.DTLSFlight.EpochMessage is used as parameter in method void org.eclipse.californium.scandium.dtls.DTLSFlight::wrapMessage(org.eclipse.californium.scandium.dtls.DTLSFlight.EpochMessage) throws org.eclipse.californium.scandium.dtls.HandshakeException <- org.eclipse.californium.scandium.dtls.DTLSFlight is returned from method org.eclipse.californium.scandium.dtls.DTLSFlight org.eclipse.californium.scandium.dtls.Handshaker::createFlight() <- org.eclipse.californium.scandium.dtls.Handshaker is used as parameter in method void org.eclipse.californium.scandium.dtls.SessionListener::handshakeFlightRetransmitted(org.eclipse.californium.scandium.dtls.Handshaker, int) <- org.eclipse.californium.scandium.dtls.SessionListener is returned from method org.eclipse.californium.scandium.dtls.SessionListener org.eclipse.californium.scandium.dtls.Connection::getSessionListener() <- org.eclipse.californium.scandium.dtls.Connection is used as parameter in method void org.eclipse.californium.scandium.MdcConnectionListener::updateExecution(org.eclipse.californium.scandium.dtls.Connection) @ org.eclipse.leshan.transport.californium.PrincipalMdcConnectionListener (method void org.eclipse.californium.scandium.MdcConnectionListener::updateExecution(org.eclipse.californium.scandium.dtls.Connection) @ org.eclipse.leshan.transport.californium.PrincipalMdcConnectionListener is part of the API)",
  "package": "org.eclipse.californium.scandium.dtls",
  "classQualifiedName": "org.eclipse.californium.scandium.dtls.DTLSFlight.EpochMessage",
  "elementKind": "class",
  "newArchive": "org.eclipse.californium:scandium:jar:3.12.0",
  "newArchiveRole": "supplementary",

},

nonPublicPartOfAPI is described here.

I copy/paste the exampleUseChainInNewApi here because this is the most important part to understand the issue :

org.eclipse.californium.scandium.dtls.DTLSFlight.EpochMessage is used as parameter in method void org.eclipse.californium.scandium.dtls.DTLSFlight::wrapMessage(org.eclipse.californium.scandium.dtls.DTLSFlight.EpochMessage) throws org.eclipse.californium.scandium.dtls.HandshakeException <- org.eclipse.californium.scandium.dtls.DTLSFlight is returned from method org.eclipse.californium.scandium.dtls.DTLSFlight org.eclipse.californium.scandium.dtls.Handshaker::createFlight() <- org.eclipse.californium.scandium.dtls.Handshaker is used as parameter in method void org.eclipse.californium.scandium.dtls.SessionListener::handshakeFlightRetransmitted(org.eclipse.californium.scandium.dtls.Handshaker, int) <- org.eclipse.californium.scandium.dtls.SessionListener is returned from method org.eclipse.californium.scandium.dtls.SessionListener org.eclipse.californium.scandium.dtls.Connection::getSessionListener() <- org.eclipse.californium.scandium.dtls.Connection is used as parameter in method void org.eclipse.californium.scandium.MdcConnectionListener::updateExecution(org.eclipse.californium.scandium.dtls.Connection) @ org.eclipse.leshan.transport.californium.PrincipalMdcConnectionListener (method void org.eclipse.californium.scandium.MdcConnectionListener::updateExecution(org.eclipse.californium.scandium.dtls.Connection) @ org.eclipse.leshan.transport.californium.PrincipalMdcConnectionListener is part of the API)", "package": "org.eclipse.californium.scandium.dtls

Solution ?

I think EpochMessage class should be protected instead of private ?

I know this is part of @NoPublicAPI but even if this is not intended to be used the visibility seems inconsistent.

(tested with Cf 3.12.0)

boaks commented 4 months ago

For me this seems to be a leftover protected in

    protected final void wrapMessage(EpochMessage epochMessage) throws HandshakeException {

and I would prefer to change that to private in 4.0.

boaks commented 1 month ago

Just in the case, you have some time left, you may check branch 4.0.x if that "works for you".