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

one of HmsSettings apply functions recurses indefinitely (huawei-push-kit) #142

Merged
merged 3 commits into from Jun 8, 2023

Conversation

pjfanning
Copy link
Contributor

@pjfanning pjfanning commented Jun 8, 2023

  • Function accidentally calls itself instead of delegating to another apply function.
  • the equivalent Java API create method uses the broken apply function
  • found by Scala 3 compiler
  • fixed by calling default apply function and passing on the default values for the 2 extra params that are needed

@pjfanning pjfanning added the bug Something isn't working label Jun 8, 2023
@@ -123,7 +123,8 @@ object HmsSettings {
def apply(
appId: String,
appSecret: String,
forwardProxy: Option[ForwardProxy]): HmsSettings = apply(appId, appSecret, forwardProxy)
forwardProxy: Option[ForwardProxy]): HmsSettings =
apply(appId, appSecret, IsTest, MaxConcurrentConnections, forwardProxy)
Copy link
Member

@He-Pin He-Pin Jun 8, 2023

Choose a reason for hiding this comment

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

Copy link
Member

@He-Pin He-Pin left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@mdedetrich mdedetrich left a comment

Choose a reason for hiding this comment

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

ill approve although I don't really like unit tests that are testing just the compiler. Since we are going to integrate Scala 3 into pekko-connectors anyways (which as you said catches this at compile time), I would prefer not having the test or alternately creating an issue to remove it when we add scala 3 support.

@pjfanning
Copy link
Contributor Author

ill approve although I don't really like unit tests that are testing just the compiler. Since we are going to integrate Scala 3 into pekko-connectors anyways, I would prefer not having the test or alternately creating an issue to remove it when we add scala 3 support.

I'm not testing the compiler - I'm testing that the call completes ok - the test runs into an indefinite loop without my fix

@mdedetrich
Copy link
Contributor

mdedetrich commented Jun 8, 2023

ill approve although I don't really like unit tests that are testing just the compiler. Since we are going to integrate Scala 3 into pekko-connectors anyways, I would prefer not having the test or alternately creating an issue to remove it when we add scala 3 support.

I'm not testing the compiler - I'm testing that the call completes ok - the test runs into an indefinite loop without my fix

Yes I know, I didn't expressive well. What I mean is that I am not a fan of unit tests that are covering for issues that the compiler should detect/show mainly because you can argue "why don't we just add a unit test for every possible apply method that can create an infinite recursive loop". Put differently the test sticks out as a sore thumb, and the impression of someone else reading this test for the first time would be "why is it only this function that has this problem" when this is not the case. This has also revealed that huawei pushkit evidently doesn't have good enough integration test coverage (which would not only uncover this issue but actually test the library in general).

As I said though, I wouldn't be saying this if Scala 3 didn't happen to catch this.

@pjfanning
Copy link
Contributor Author

@mdedetrich unfortunately, the Scala 3 build just logs a warning - it does not fail

We can play around with the Scala 3 settings to see if we can make the warnings lead to a build failure.

@mdedetrich
Copy link
Contributor

@mdedetrich unfortunately, the Scala 3 build just logs a warning - it does not fail

Unless I am mistaken any warning can be turned into a fatal error, so this shouldn't be an issue

We can play around with the Scala 3 settings to see if we can make the warnings lead to a build failure.

👍

@pjfanning pjfanning merged commit 8b157df into apache:main Jun 8, 2023
50 checks passed
@pjfanning pjfanning deleted the infinite-recursion branch June 8, 2023 13:06
@pjfanning pjfanning added the release note should be mentioned in release notes label Jun 8, 2023
@pjfanning pjfanning added this to the 1.0.0 milestone Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working release note should be mentioned in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants