Skip to content

Techdebt/remove guava#1924

Merged
ThomasSession merged 10 commits intodevfrom
techdebt/remove-guava
Feb 12, 2026
Merged

Techdebt/remove guava#1924
ThomasSession merged 10 commits intodevfrom
techdebt/remove-guava

Conversation

@ThomasSession
Copy link
Collaborator

Removing our dependency on a local guava.Optional class

@ThomasSession ThomasSession marked this pull request as ready for review February 11, 2026 23:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the project’s dependency on the local org.session.libsignal.utilities.guava.Optional (and related guava shims) by migrating call sites to Kotlin nullables / Java nullability and converting several Java classes to Kotlin equivalents.

Changes:

  • Replaced usages of guava.Optional/Preconditions with Kotlin/Java nullability and standard argument checks.
  • Migrated multiple classes from Java → Kotlin (notably around link previews, attachments, and request controllers) and updated call sites accordingly.
  • Deleted the local guava shim package and several legacy SignalService model classes that depended on it.

Reviewed changes

Copilot reviewed 72 out of 72 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
app/src/main/java/org/thoughtcrime/securesms/webrtc/locks/ProximityLock.kt Kotlin replacement for proximity wakelock wrapper without Optional.
app/src/main/java/org/thoughtcrime/securesms/webrtc/locks/ProximityLock.java Removed Java implementation that used Optional.
app/src/main/java/org/thoughtcrime/securesms/util/SessionMetaProtocol.kt Removed unused delivery receipt helper that depended on removed SignalService types/Optional.
app/src/main/java/org/thoughtcrime/securesms/service/ExpiringMessageManager.kt Replaced .orNull()-style Optional handling with Kotlin nullability.
app/src/main/java/org/thoughtcrime/securesms/reactions/any/ReactWithAnyEmojiPage.java Replaced guava Preconditions with standard argument validation.
app/src/main/java/org/thoughtcrime/securesms/net/ChunkedDataFetcher.java Replaced Optional with @Nullable values for chunk logic.
app/src/main/java/org/thoughtcrime/securesms/net/CallRequestController.kt Kotlin replacement for request controller without Optional.
app/src/main/java/org/thoughtcrime/securesms/net/CallRequestController.java Removed Java implementation that used Optional.
app/src/main/java/org/thoughtcrime/securesms/mms/SlideDeck.java Removed Optional usage in body selection logic.
app/src/main/java/org/thoughtcrime/securesms/mms/Slide.kt Migrated slide body/caption and mime resolution away from Optional.
app/src/main/java/org/thoughtcrime/securesms/mms/SignalGlideModule.java Updated Glide registration to reference Kotlin nested model type directly.
app/src/main/java/org/thoughtcrime/securesms/mms/AttachmentStreamUriLoader.kt Kotlin loader replacement for attachment stream model/fetcher wiring.
app/src/main/java/org/thoughtcrime/securesms/mms/AttachmentStreamUriLoader.java Removed Java implementation that used Optional.
app/src/main/java/org/thoughtcrime/securesms/mms/AttachmentStreamLocalUriFetcher.kt Kotlin fetcher replacement without Optional.
app/src/main/java/org/thoughtcrime/securesms/mms/AttachmentStreamLocalUriFetcher.java Removed Java implementation that used Optional.
app/src/main/java/org/thoughtcrime/securesms/mediasend/MediaSendViewModel.kt Replaced Optional state with nullable types.
app/src/main/java/org/thoughtcrime/securesms/mediasend/MediaRepository.java Replaced Optional<Long> with nullable Long.
app/src/main/java/org/thoughtcrime/securesms/mediapreview/MediaPreviewViewModel.java Removed Optional import (cleanup).
app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewViewModel.kt Kotlin replacement for link preview VM without Optional.
app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewViewModel.java Removed Java implementation that used Optional.
app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewUtil.java Replaced Optional title/image accessors and adjusted date parsing.
app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.kt Kotlin replacement for link preview repository without Optional.
app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java Removed Java implementation that used Optional.
app/src/main/java/org/thoughtcrime/securesms/home/startconversation/group/CreateGroupViewModel.kt Replaced .orNull() calls with nullable results.
app/src/main/java/org/thoughtcrime/securesms/home/ConversationOptionsBottomSheet.kt Updated group fetch/admin checks to use null-safe access.
app/src/main/java/org/thoughtcrime/securesms/giph/ui/GiphyStickerFragment.kt Removed unused annotation import.
app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt Replaced Optional plumbing with nullable types; updated pointer conversion usage.
app/src/main/java/org/thoughtcrime/securesms/database/SmsDatabase.java Converted inbox/outbox insert APIs from Optional to @Nullable return.
app/src/main/java/org/thoughtcrime/securesms/database/RecipientRepository.kt Updated group lookup away from .orNull().
app/src/main/java/org/thoughtcrime/securesms/database/PushDatabase.java Converted Optional<Long> to nullable Long, removed unused Reader API.
app/src/main/java/org/thoughtcrime/securesms/database/MmsDatabase.kt Converted Optional returns/params to nullable types; updated link preview thumbnail access.
app/src/main/java/org/thoughtcrime/securesms/database/GroupDatabase.java Converted Optional<GroupRecord> to nullable and updated call sites.
app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/AttachmentManager.java Replaced Optional<Slide> with nullable Slide.
app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt Updated link preview thumbnail access to nullable property.
app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/LinkPreviewView.kt Updated link preview thumbnail access to nullable property.
app/src/main/java/org/thoughtcrime/securesms/conversation/v2/components/LinkPreviewDraftView.kt Updated link preview thumbnail access to nullable property.
app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModel.kt Updated group lookups away from .orNull().
app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt Updated link preview VM API usage away from Optional.
app/src/main/java/org/thoughtcrime/securesms/components/emoji/EmojiTextView.java Removed Optional usage in text concatenation.
app/src/main/java/org/thoughtcrime/securesms/attachments/DatabaseAttachmentProvider.kt Updated attachment pointer/stream construction to new non-Optional models.
app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.kt Updated caption extra to use nullable caption directly.
app/src/main/java/org/session/libsignal/utilities/guava/* Deleted local guava shim types (Optional, Preconditions, etc.).
app/src/main/java/org/session/libsignal/messages/SignalServiceAttachment.kt Kotlin replacement for attachment base type (no Optional).
app/src/main/java/org/session/libsignal/messages/SignalServiceAttachmentPointer.kt Kotlin replacement for attachment pointer (no Optional).
app/src/main/java/org/session/libsignal/messages/SignalServiceAttachmentStream.kt Kotlin replacement for attachment stream (no Optional).
app/src/main/java/org/session/libsession/messaging/sending_receiving/link_preview/LinkPreview.kt Kotlin replacement for LinkPreview with nullable thumbnail.
app/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/PointerAttachment.kt Kotlin replacement for pointer attachment conversions without Optional.
app/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/SessionServiceAttachmentStream.kt Updated to nullable fields instead of Optional.
app/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/SessionServiceAttachmentPointer.kt Updated to nullable fields instead of Optional.
app/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/SessionServiceAttachment.kt Updated builder to construct new nullable-based stream type.
app/src/main/java/org/session/libsession/messaging/sending_receiving/VisibleMessageHandler.kt Updated preview parsing to use nullable fields and new thumbnail representation.
app/src/main/java/org/session/libsession/messaging/messages/visible/Attachment.kt Updated attachment pointer creation to use new pointer model (no Optional).
app/src/main/java/org/session/libsession/utilities/Util.kt Updated readFully* nullability contracts; wait signature change.
app/src/main/java/org/session/libsession/messaging/utilities/UpdateMessageData.kt Removed helper depending on removed SignalServiceGroup.
app/src/main/java/org/session/libsignal/messages/SignalServiceEnvelope.java Removed methods depending on removed SignalServiceAddress.
app/src/main/java/org/session/libsignal/utilities/SignalServiceAddress.java Removed legacy address type dependent on Optional.
app/src/main/java/org/session/libsignal/messages/SignalServiceGroup.java Removed legacy group type dependent on Optional.
app/src/main/java/org/session/libsignal/messages/SignalServiceDataMessage.java Removed legacy data message type dependent on Optional.
app/src/main/java/org/session/libsignal/messages/SharedContact.java Removed legacy shared contact type dependent on Optional.
app/src/main/java/org/session/libsignal/streams/* Removed legacy stream/request body helpers that depended on removed types.
Comments suppressed due to low confidence (1)

app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewUtil.java:211

  • parseISO8601() now always uses the ...ssZ pattern. This will fail to parse valid ISO-8601 timestamps that include a colon in the timezone offset (e.g. +00:00), which the previous ...ssX handled on API 24+. Restore support for X (or use a more robust ISO-8601 parser) to avoid link preview date parsing regressions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +21 to +30
override fun cancel() {
// Don't block the caller; cancel on a background thread
if (!canceled.compareAndSet(false, true)) return

thread(name = "CallRequestController-cancel", isDaemon = true) {
call.cancel()
stream?.let(Util::close)
stream = null
done.countDown()
}
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

cancel() spawns a new dedicated thread per call and only releases getStream() waiters after that thread runs. This can create unnecessary threads and can delay unblocking if the scheduler is busy; prefer dispatching to an existing executor (e.g. SignalExecutors) and consider calling done.countDown() immediately after marking canceled (then close/cancel in background).

Copilot uses AI. Check for mistakes.
@ThomasSession ThomasSession merged commit bebd74d into dev Feb 12, 2026
5 checks passed
@ThomasSession ThomasSession deleted the techdebt/remove-guava branch February 12, 2026 04:27
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.

3 participants