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
Attempt at fixing https://github.com/robolectric/robolectric/issues/8242 #8250
Conversation
@alixwar please squash to one commit. |
Done @utzcoz |
@alixwar There are some code formatting errors. Please check https://github.com/robolectric/robolectric/wiki/Robolectric's-code-style how to fix it. |
And I prefer to write a more reasonable commit message like "Intercept Cipher#getCurrentSpi to avoid running error". |
robolectric/src/test/java/org/robolectric/interceptors/AndroidInterceptorsTest.java
Outdated
Show resolved
Hide resolved
a3af347
to
d83a34c
Compare
@alwa Do you test it with local snapshot building for your project? Can it fix your issue? |
@alwa This PR still has formatting issues. I recommend you to run it locally to ensure code formatting job will happy to reduce feedback time. See the abvoe link I posted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix code formatting for AndroidInterceptors.java
.
These instructions are not Windows-friendly, so I can't really follow them: https://github.com/robolectric/robolectric/wiki/Running-google-java-format Since this is a trivial change I'm sure I can fix the formatting manually if I can just understand what's wrong with my changes. Update: OK, I think I got it now. I removed some indentation that caused the check to fail. This project does not play well with my own formatting rules in the IDE. I have run |
@alwa I think only |
They are left formatting errors. I still recommend you to run it locally. |
It wasn't easy but I managed to run it locally now |
Is it stuck? Can it be restarted? |
Never mind. It hangs because of M1 GitHub Action configuration changed, and the self-hosted M1 machine doesn't update. I have another question, do you test it with local snapshot for your demo? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
sandbox/src/main/java/org/robolectric/interceptors/AndroidInterceptors.java
Show resolved
Hide resolved
@alwa Thanks for your contribution. Please test it with official robolectric 11 snapshot, and give feedback here. Thanks. |
I have issues building the project locally:
I tried with both JDK 8 and 11. In the build log I see many errors related to javadoc. Example error from the stack trace:
|
@alwa You need to use JDK 9+, and JDK 11 is very recommended. These errors are related to JavaDoc, you can omit them if you don't want to help improve JavaDoc. |
Thanks. Building with JDK11 works if I skip the javadoc step. I'm not sure what needs to be fixed locally for this to also work but in the context of this bug fix it is enough if I can deploy the main jar locally. |
This is disheartening, it looks as if I can still reproduce the issue:
What I did:
In my IDE I can see that the robolectric dependencies are listed correctly as belonging to version 4.11-SNAPSHOT. But I'll make some more checks to really confirm this. We have some shadows and rules that may interfere... |
@alwa You can use online 4.11-snapshot now. See the README.md to learn how to use it. |
Same issue I'm afraid. Full stacktrace (my company class names obfuscated):
|
@alwa I think it is related to the following code:
Maybe you need to change |
I'll create a new PR |
@alwa You can test it locally before you pushing. I can't confirm the above solution can fix this issue. |
To get an end to end test working you either need to regenerate preinstrumented jars or disable preinstrumented jars. To release a version with this change we also have a bump the preinstrumented jar level. This may have been why you didn't see it working. |
@hoisie Instead of intercepting, adding shadow for upper call method is might be better. |
It is better to intercept these in case they are called from multiple places in framework code. It's not a big deal to bump the preinstrumented level. We can bump it on |
The initial fix was reverted though. Let me know when to try |
I have been thinking a bit about the best way to write an end-to-end unit test for this. The current https://github.com/robolectric/robolectric/blob/master/robolectric/src/test/java/org/robolectric/interceptors/AndroidInterceptorsIntegrationTest.java is not great because it doesn't actually test the instrumentation part. Ideally it would be something like using ASM to generate a class that has a method that calls |
Overview
#8242
Proposed Changes
Add extra interceptor for Cipher to handle getCurrentSpi()