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

Fix crash in CommentsScreen due to incorrect timestamp parsing #214

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thesohelshaikh
Copy link

@thesohelshaikh thesohelshaikh commented Nov 3, 2024

Description

Fixes a crash when navigating to CommentsScreen due to incorrect parsing of timestamp. The returned timestamp withing HTML also contains millis which causes the parsing to fail.

Actual: 2024-11-03T04:53:41 1730609621
Expected: 2024-11-03T04:53:41

This diff simply strips the millis and only uses timestamp to parse the date.

Steps to reproduce

  1. Navigate to Comments screen for any post
  2. Notice that the app crashes without the change

Crash Logs

Stacktrace
FATAL EXCEPTION: main (Ask Gemini)
                                                                                                    Process: com.emergetools.hackernews.debug, PID: 4649
                                                                                                    java.time.format.DateTimeParseException: Text '2024-11-02T20:55:10 1730580910' could not be parsed, unparsed text found at index 19
                                                                                                    	at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2053)
                                                                                                    	at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1952)
                                                                                                    	at java.time.LocalDateTime.parse(LocalDateTime.java:487)
                                                                                                    	at com.emergetools.hackernews.features.comments.CommentsViewModel.toCommentState(CommentsDomain.kt:356)
                                                                                                    	at com.emergetools.hackernews.features.comments.CommentsViewModel.access$toCommentState(CommentsDomain.kt:176)
                                                                                                    	at com.emergetools.hackernews.features.comments.CommentsViewModel$1.invokeSuspend(CommentsDomain.kt:208)
                                                                                                    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                    	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                    	at android.os.Looper.loop(Looper.java:294)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8177)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
                                                                                                    	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@b0924ad, Dispatchers.Main.immediate]

Fixes a crash when navigating to CommentsScreen due to incorrect
parsing of timestamp. The returned timestamp withing HTML also contains
millis which causes the parsing to fail.

Actual: 2024-11-03T04:53:41 1730609621
Expected: 2024-11-03T04:53:41

This diff simply strips the millis and only timestamp to parse the date.
@thesohelshaikh
Copy link
Author

@rbro112 @Rahkeen Is it possible get this fixed? I think this is critical and makes the app unusable for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant