-
-
Notifications
You must be signed in to change notification settings - Fork 440
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: Allow MaxBreadcrumb 0 / Expose MaxBreadcrumb metadata. #3836
Merged
+257
−1
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d282d06
expose max-breadcrumbs on meta data and implement disabled queue when…
4371e95
missing queue class and test
cc180a9
Merge branch 'main' into fix/0-breadcrumb
lucas-zimerman 3e51f6c
update changelog
5f9ef0f
./gradlew :spotlessApply
a99280f
Merge branch 'main' into fix/0-breadcrumb
lucas-zimerman d581e91
Update sentry-android-core/src/test/java/io/sentry/android/core/Manif…
lucas-zimerman d0fa3b8
Update sentry-android-core/src/test/java/io/sentry/android/core/Manif…
lucas-zimerman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package io.sentry; | ||
|
||
import java.io.Serializable; | ||
import java.util.AbstractCollection; | ||
import java.util.Iterator; | ||
import java.util.NoSuchElementException; | ||
import java.util.Queue; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
final class DisabledQueue<E> extends AbstractCollection<E> implements Queue<E>, Serializable { | ||
|
||
/** Serialization version. */ | ||
private static final long serialVersionUID = -8423413834657610417L; | ||
|
||
/** Constructor that creates a queue that does not accept any element. */ | ||
public DisabledQueue() {} | ||
|
||
// ----------------------------------------------------------------------- | ||
/** | ||
* Returns the number of elements stored in the queue. | ||
* | ||
* @return this queue's size | ||
*/ | ||
@Override | ||
public int size() { | ||
return 0; | ||
} | ||
|
||
/** | ||
* Returns true if this queue is empty; false otherwise. | ||
* | ||
* @return false | ||
*/ | ||
@Override | ||
public boolean isEmpty() { | ||
return false; | ||
} | ||
|
||
/** Does nothing. */ | ||
@Override | ||
public void clear() {} | ||
|
||
/** | ||
* Since the queue is disabled, the element will not be added. | ||
* | ||
* @param element the element to add | ||
* @return false, always | ||
*/ | ||
@Override | ||
public boolean add(final @NotNull E element) { | ||
return false; | ||
} | ||
|
||
// ----------------------------------------------------------------------- | ||
|
||
/** | ||
* Receives an element but do nothing with it. | ||
* | ||
* @param element the element to add | ||
* @return false, always | ||
*/ | ||
@Override | ||
public boolean offer(@NotNull E element) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public @Nullable E poll() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable E element() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable E peek() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @NotNull E remove() { | ||
throw new NoSuchElementException("queue is disabled"); | ||
} | ||
|
||
// ----------------------------------------------------------------------- | ||
|
||
/** | ||
* Returns an iterator over this queue's elements. | ||
* | ||
* @return an iterator over this queue's elements | ||
*/ | ||
@Override | ||
public @NotNull Iterator<E> iterator() { | ||
return new Iterator<E>() { | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public E next() { | ||
throw new NoSuchElementException(); | ||
} | ||
|
||
@Override | ||
public void remove() { | ||
throw new IllegalStateException(); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package io.sentry | ||
import org.junit.Assert.assertThrows | ||
import java.util.NoSuchElementException | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertFalse | ||
import kotlin.test.assertNull | ||
|
||
class DisabledQueueTest { | ||
|
||
@Test | ||
fun `size starts empty`() { | ||
val queue = DisabledQueue<Int>() | ||
assertEquals(0, queue.size, "Size should always be zero.") | ||
} | ||
|
||
@Test | ||
fun `add does not add elements`() { | ||
val queue = DisabledQueue<Int>() | ||
assertFalse(queue.add(1), "add should always return false.") | ||
assertEquals(0, queue.size, "Size should still be zero after attempting to add an element.") | ||
} | ||
|
||
@Test | ||
fun `isEmpty returns false when created`() { | ||
val queue = DisabledQueue<Int>() | ||
assertFalse(queue.isEmpty(), "isEmpty should always return false.") | ||
} | ||
|
||
@Test | ||
fun `isEmpty always returns false if add function was called`() { | ||
val queue = DisabledQueue<Int>() | ||
queue.add(1) | ||
|
||
assertFalse(queue.isEmpty(), "isEmpty should always return false.") | ||
} | ||
|
||
@Test | ||
fun `offer does not add elements`() { | ||
val queue = DisabledQueue<Int>() | ||
assertFalse(queue.offer(1), "offer should always return false.") | ||
assertEquals(0, queue.size, "Size should still be zero after attempting to offer an element.") | ||
} | ||
|
||
@Test | ||
fun `poll returns null`() { | ||
val queue = DisabledQueue<Int>() | ||
queue.add(1) | ||
assertNull(queue.poll(), "poll should always return null.") | ||
} | ||
|
||
@Test | ||
fun `peek returns null`() { | ||
val queue = DisabledQueue<Int>() | ||
queue.add(1) | ||
|
||
assertNull(queue.peek(), "peek should always return null.") | ||
} | ||
|
||
@Test | ||
fun `element returns null`() { | ||
val queue = DisabledQueue<Int>() | ||
assertNull(queue.element(), "element should always return null.") | ||
} | ||
|
||
@Test | ||
fun `remove throws NoSuchElementException`() { | ||
val queue = DisabledQueue<Int>() | ||
assertThrows(NoSuchElementException::class.java) { queue.remove() } | ||
} | ||
|
||
@Test | ||
fun `clear does nothing`() { | ||
val queue = DisabledQueue<Int>() | ||
queue.clear() // Should not throw an exception | ||
assertEquals(0, queue.size, "Size should remain zero after clear.") | ||
} | ||
|
||
@Test | ||
fun `iterator has no elements`() { | ||
val queue = DisabledQueue<Int>() | ||
val iterator = queue.iterator() | ||
assertFalse(iterator.hasNext(), "Iterator should have no elements.") | ||
assertThrows(NoSuchElementException::class.java) { iterator.next() } | ||
} | ||
|
||
@Test | ||
fun `iterator remove throws IllegalStateException`() { | ||
val queue = DisabledQueue<Int>() | ||
val iterator = queue.iterator() | ||
assertThrows(IllegalStateException::class.java) { iterator.remove() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@lucas-zimerman @stefanosiano should this return
true
instead? If no, can we document why?