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

Added logging unsupported content type #1713

Closed
wants to merge 24 commits into from
Closed

Conversation

oleg-smith
Copy link

No description provided.

@akka-ci
Copy link

akka-ci commented Dec 25, 2017

Can one of the repo owners verify this patch?

@jlprat
Copy link
Member

jlprat commented Dec 25, 2017

OK TO TEST

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed validating PR that is currently being validated by Jenkins labels Dec 25, 2017
@akka-ci
Copy link

akka-ci commented Dec 25, 2017

Test FAILed.

@oleg-smith
Copy link
Author

@jlprat Do you think the binary compatibility problem can be ignored?

@jlprat
Copy link
Member

jlprat commented Dec 25, 2017

Sorry I'm not close to a computer now, I will take a look later, but as a general rule binary compatible problems can only be "ignored" if the class is labeled as @InternalApi or @ApiMayChange. There are other cases when adding methods though.

@jlprat
Copy link
Member

jlprat commented Dec 26, 2017

Hi @oleg-smith
Sorry for the delay, but I was away from a computer. IMO this change is binary incompatible the way it is. For example, the Exception UnsupportedContentTypeException now has a different constructor and any 3rd party library built upon previous versions of Akka HTTP will fail if we introduce this change.
I would try to implement this change in a compatible way, for example, offering 2 constructors and some default value for contentType.

@jlprat
Copy link
Member

jlprat commented Dec 26, 2017

One extra thing, is there an issue for this PR?

@oleg-smith
Copy link
Author

Yes, #1691

@oleg-smith
Copy link
Author

Will implement it in compatible way.

oleg added 3 commits December 30, 2017 23:19
# Conflicts:
#	akka-http/src/main/scala/akka/http/scaladsl/common/StrictForm.scala
#	akka-http/src/main/scala/akka/http/scaladsl/server/directives/MarshallingDirectives.scala
#	akka-http/src/main/scala/akka/http/scaladsl/unmarshalling/Unmarshaller.scala
@akka-ci akka-ci added validating PR that is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR that is currently being validated by Jenkins labels Dec 30, 2017
@akka-ci
Copy link

akka-ci commented Dec 30, 2017

Test FAILed.

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR that is currently being validated by Jenkins labels Dec 31, 2017
@akka-ci
Copy link

akka-ci commented Dec 31, 2017

Test FAILed.

@akka-ci akka-ci added the validating PR that is currently being validated by Jenkins label Jan 1, 2018
@akka-ci akka-ci added tested PR that was successfully built and tested by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR that is currently being validated by Jenkins labels Sep 16, 2018
@akka-ci
Copy link

akka-ci commented Sep 16, 2018

Test PASSed.

@oleg-smith
Copy link
Author

@raboof Could you merge this?

Copy link
Member

@johanandren johanandren left a comment

Choose a reason for hiding this comment

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

I think this requires some further work before it can be merged. Mostly small things though.

@@ -122,7 +122,7 @@ class GracefulTerminationSpec extends WordSpec with Matchers with BeforeAndAfter

"in-flight request responses should include Connection: close and connection should be closed" in new TestSetup {
val r1 = makeRequest() // establish connection
val time: FiniteDuration = 3.seconds
val time: FiniteDuration = 6.seconds
Copy link
Member

Choose a reason for hiding this comment

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

This is unrelated, revert.

Copy link
Author

Choose a reason for hiding this comment

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

This test fails due to lack of time on Jenkins. How can I make the unrelated test to pass otherwise?

Copy link
Member

Choose a reason for hiding this comment

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

Then it should fail for all other PR validation and our nightlies on Jenkins as well, which I'm pretty sure it doesn't.

Copy link
Author

Choose a reason for hiding this comment

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

No, it should not - it can fail from time to time depending on agent.

@@ -125,10 +126,10 @@ object StrictForm {
}

tryUnmarshalToQueryForm.fast.recoverWith {
case Unmarshaller.UnsupportedContentTypeException(supported1) ⇒
case UnsupportedContentTypeException(supported1, _) ⇒
Copy link
Member

Choose a reason for hiding this comment

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

if this is required we still have a binary compatibility problem, I think we need the single param unapply or else it could potentially break usage like the old one.

Copy link
Author

Choose a reason for hiding this comment

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

isn't binary compatibility checked automatically so nobody guesses about it?

Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately there are some cases that are not yet caught by MiMa, and this is one of them: lightbend-labs/mima#40

override def getSupported: java.util.Set[model.ContentTypeRange] =
scala.collection.mutable.Set(supported.map(_.asJava).toVector: _*).asJava // TODO optimise

@deprecated("for binary compatibility")
Copy link
Member

Choose a reason for hiding this comment

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

All these should have a version as well, so @deprecated("Something something", since = "10.1.6"), they should also rather mention what to use instead. So, in this case "Use the two parameter constructor instead".

For the copy I guess the alternative now is to create a new object manually, so same there.

def copy(
supported: Set[ContentTypeRange] = this.supported,
contentType: Option[ContentType] = this.contentType) =
UnsupportedRequestContentTypeRejection(supported, contentType)
Copy link
Member

Choose a reason for hiding this comment

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

This is the new two-param copy so it shouldn't be deprecated?

supported = supported.asScala.map(m ⇒ scaladsl.model.ContentTypeRange(m.asScala)).toSet,
contentType = contentType.asScala.map(_.asScala))

// for backwards compatibility
Copy link
Member

Choose a reason for hiding this comment

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

should be marked deprecated as well

@@ -257,7 +257,8 @@ object RejectionHandler {
}
.handleAll[UnsupportedRequestContentTypeRejection] { rejections ⇒
val supported = rejections.flatMap(_.supported).mkString(" or ")
rejectRequestEntityAndComplete((UnsupportedMediaType, "The request's Content-Type is not supported. Expected:\n" + supported))
val unsupportedContentType = rejections.find(_.contentType.isDefined).map(_.contentType)
Copy link
Member

Choose a reason for hiding this comment

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

This will be an Option[Option[ContentType]] now. I think you can just do a rejections.flatMap(_.contentType) instead.

* Helper for creating a "super-unmarshaller" from a sequence of "sub-unmarshallers", which are tried
* in the given order. The first successful unmarshalling of a "sub-unmarshallers" is the one produced by the
* "super-unmarshaller".
*/
Copy link
Member

Choose a reason for hiding this comment

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

This is not the scaladoc style we use, please revert

Copy link
Author

Choose a reason for hiding this comment

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

doesn't validatePullRequest format code properly?

Copy link
Member

Choose a reason for hiding this comment

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

Could be that it doesn't reformat scaladoc, not sure.

Copy link
Member

Choose a reason for hiding this comment

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

I am also surprised that scalariform doesn't update this indentation, but I just checked and indeed it doesn't.

Copy link
Member

@raboof raboof left a comment

Choose a reason for hiding this comment

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

Are you still interested in having a look at these review comments?

@oleg-smith
Copy link
Author

@raboof yeah, will do

@akka-ci
Copy link

akka-ci commented Feb 12, 2019

Thank you for your pull request! After a quick sanity check one of the team will reply with 'OK TO TEST' to kick off our automated validation on Jenkins. This compiles the project, runs the tests, and checks for things like binary compatibility and source code formatting. When two team members have also manually reviewed and (perhaps after asking for some amendments) accepted your contribution, it should be good to be merged.

For more details about our contributing process, check out CONTRIBUTING.md - and feel free to ask!

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed tested PR that was successfully built and tested by Jenkins validating PR that is currently being validated by Jenkins labels Mar 5, 2019
@akka-ci
Copy link

akka-ci commented Mar 5, 2019

Test PASSed.

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed tested PR that was successfully built and tested by Jenkins validating PR that is currently being validated by Jenkins labels Mar 5, 2019
@akka-ci
Copy link

akka-ci commented Mar 5, 2019

Test FAILed.

raboof added a commit that referenced this pull request Apr 23, 2019
Rebased/formatted version of #1713
@raboof
Copy link
Member

raboof commented Jul 9, 2019

(closing due to inactivity, feel free to reopen when someone wants to resume this work!)

@raboof raboof closed this Jul 9, 2019
raboof added a commit that referenced this pull request Jul 9, 2019
Rebased/formatted version of #1713
raboof added a commit that referenced this pull request Jul 9, 2019
Rebased/formatted version of #1713
raboof added a commit that referenced this pull request Jul 9, 2019
Rebased/formatted version of #1713
raboof added a commit that referenced this pull request Aug 14, 2019
Rebased/formatted version of #1713
jrudolph pushed a commit that referenced this pull request Sep 9, 2019
Rebased/formatted version of #1713

Co-authored-by: oleg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-attention Indicates a PR validation failure (set by CI infrastructure)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants