Skip to content

Commit d86392a

Browse files
Add proper super boundaries to consumers in RestAction
1 parent e243060 commit d86392a

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/main/java/net/dv8tion/jda/core/exceptions/ContextException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static Consumer<Throwable> herePrintingTrace()
4747
* @return Wrapper of the provided consumer that will append a context with the current stack-trace
4848
*/
4949
@Nonnull
50-
public static Consumer<Throwable> here(@Nonnull Consumer<Throwable> acceptor)
50+
public static Consumer<Throwable> here(@Nonnull Consumer<? super Throwable> acceptor)
5151
{
5252
ContextException context = new ContextException();
5353
return (ex) ->

src/main/java/net/dv8tion/jda/core/managers/impl/ManagerBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected ManagerBase reset()
107107

108108
@Override
109109
@SuppressWarnings("unchecked")
110-
public void queue(Consumer<Void> success, Consumer<Throwable> failure)
110+
public void queue(Consumer<? super Void> success, Consumer<? super Throwable> failure)
111111
{
112112
if (shouldUpdate())
113113
super.queue(success, failure);
@@ -155,7 +155,7 @@ protected boolean shouldUpdate(long bit)
155155
return (set & bit) == bit;
156156
}
157157

158-
protected <E> void withLock(E object, Consumer<E> consumer)
158+
protected <E> void withLock(E object, Consumer<? super E> consumer)
159159
{
160160
synchronized (object)
161161
{

src/main/java/net/dv8tion/jda/core/requests/Request.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public class Request<T>
3232
{
3333
private final JDAImpl api;
3434
private final RestAction<T> restAction;
35-
private final Consumer<T> onSuccess;
36-
private final Consumer<Throwable> onFailure;
35+
private final Consumer<? super T> onSuccess;
36+
private final Consumer<? super Throwable> onFailure;
3737
private final BooleanSupplier checks;
3838
private final boolean shouldQueue;
3939
private final Route.CompiledRoute route;
@@ -43,7 +43,7 @@ public class Request<T>
4343

4444
private boolean isCanceled = false;
4545

46-
public Request(RestAction<T> restAction, Consumer<T> onSuccess, Consumer<Throwable> onFailure,
46+
public Request(RestAction<T> restAction, Consumer<? super T> onSuccess, Consumer<? super Throwable> onFailure,
4747
BooleanSupplier checks, boolean shouldQueue, RequestBody body, Object rawBody,
4848
Route.CompiledRoute route, CaseInsensitiveMap<String, String> headers)
4949
{
@@ -122,12 +122,12 @@ public RestAction<T> getRestAction()
122122
return restAction;
123123
}
124124

125-
public Consumer<T> getOnSuccess()
125+
public Consumer<? super T> getOnSuccess()
126126
{
127127
return onSuccess;
128128
}
129129

130-
public Consumer<Throwable> getOnFailure()
130+
public Consumer<? super Throwable> getOnFailure()
131131
{
132132
return onFailure;
133133
}

src/main/java/net/dv8tion/jda/core/requests/RestAction.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public void queue()
306306
* The success callback that will be called at a convenient time
307307
* for the API. (can be null)
308308
*/
309-
public void queue(Consumer<T> success)
309+
public void queue(Consumer<? super T> success)
310310
{
311311
queue(success, null);
312312
}
@@ -324,7 +324,7 @@ public void queue(Consumer<T> success)
324324
* encounters an exception at its execution point.
325325
*/
326326
@SuppressWarnings("unchecked")
327-
public void queue(Consumer<T> success, Consumer<Throwable> failure)
327+
public void queue(Consumer<? super T> success, Consumer<? super Throwable> failure)
328328
{
329329
Route.CompiledRoute route = finalizeRoute();
330330
Checks.notNull(route, "Route");
@@ -582,7 +582,7 @@ public ScheduledFuture<?> queueAfter(long delay, TimeUnit unit)
582582
* @return {@link java.util.concurrent.ScheduledFuture ScheduledFuture}
583583
* representing the delayed operation
584584
*/
585-
public ScheduledFuture<?> queueAfter(long delay, TimeUnit unit, Consumer<T> success)
585+
public ScheduledFuture<?> queueAfter(long delay, TimeUnit unit, Consumer<? super T> success)
586586
{
587587
return queueAfter(delay, unit, success, api.pool);
588588
}
@@ -615,7 +615,7 @@ public ScheduledFuture<?> queueAfter(long delay, TimeUnit unit, Consumer<T> succ
615615
* @return {@link java.util.concurrent.ScheduledFuture ScheduledFuture}
616616
* representing the delayed operation
617617
*/
618-
public ScheduledFuture<?> queueAfter(long delay, TimeUnit unit, Consumer<T> success, Consumer<Throwable> failure)
618+
public ScheduledFuture<?> queueAfter(long delay, TimeUnit unit, Consumer<? super T> success, Consumer<? super Throwable> failure)
619619
{
620620
return queueAfter(delay, unit, success, failure, api.pool);
621621
}
@@ -678,7 +678,7 @@ public ScheduledFuture<?> queueAfter(long delay, TimeUnit unit, ScheduledExecuto
678678
* @return {@link java.util.concurrent.ScheduledFuture ScheduledFuture}
679679
* representing the delayed operation
680680
*/
681-
public ScheduledFuture<?> queueAfter(long delay, TimeUnit unit, Consumer<T> success, ScheduledExecutorService executor)
681+
public ScheduledFuture<?> queueAfter(long delay, TimeUnit unit, Consumer<? super T> success, ScheduledExecutorService executor)
682682
{
683683
return queueAfter(delay, unit, success, null, executor);
684684
}
@@ -711,7 +711,7 @@ public ScheduledFuture<?> queueAfter(long delay, TimeUnit unit, Consumer<T> succ
711711
* @return {@link java.util.concurrent.ScheduledFuture ScheduledFuture}
712712
* representing the delayed operation
713713
*/
714-
public ScheduledFuture<?> queueAfter(long delay, TimeUnit unit, Consumer<T> success, Consumer<Throwable> failure, ScheduledExecutorService executor)
714+
public ScheduledFuture<?> queueAfter(long delay, TimeUnit unit, Consumer<? super T> success, Consumer<? super Throwable> failure, ScheduledExecutorService executor)
715715
{
716716
Checks.notNull(executor, "Scheduler");
717717
Checks.notNull(unit, "TimeUnit");
@@ -765,7 +765,7 @@ public EmptyRestAction(JDA api, T returnObj)
765765
}
766766

767767
@Override
768-
public void queue(Consumer<T> success, Consumer<Throwable> failure)
768+
public void queue(Consumer<? super T> success, Consumer<? super Throwable> failure)
769769
{
770770
if (success != null)
771771
success.accept(returnObj);

src/main/java/net/dv8tion/jda/core/requests/restaction/AuditableRestAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public EmptyRestAction(JDA api, T content)
134134
}
135135

136136
@Override
137-
public void queue(Consumer<T> success, Consumer<Throwable> failure)
137+
public void queue(Consumer<? super T> success, Consumer<? super Throwable> failure)
138138
{
139139
if (success != null)
140140
success.accept(content);

0 commit comments

Comments
 (0)