#help using async runnables and CompletableFuture

1 messages · Page 1 of 1 (latest)

bright rock
#

hi so i've been trying to make an http request asynchronous because i know how much it could fuck up a server if not so i've done a little research into using CompletableFuture to try and get this working

Main Class:
https://paste.md-5.net/qozijayele.java

Command Class:
https://paste.md-5.net/uzeyivelav.java

API Request Class:
https://paste.md-5.net/aciwujasuw.java

Listener Class:
https://paste.md-5.net/iduvenuqor.java

The thing is that this works fine, but then my server starts lagging out (I think there is a memory leak here somewhere but I don't know where to find it)

If someone could help me either find a better way of doing this or helping me solve this, it would be much appreciated

midnight pecan
#

And what isn't working

bright rock
#

sorry was editing my message

midnight pecan
#

You don't need to run async with both completablefuture and bukkit Runnable

bright rock
#

the thing is i need it or something like it so i can get a return value from my api request class

#

since i'm running it asyncronously

midnight pecan
#

You can't run it async then if you want return

#

Can't return without blocking

#

But you can use callbacks

#

See about Consumer

bright rock
#

@midnight pecan so are you saying to just remove the async runnable

#

or what are you suggesting

midnight pecan
#

Can't really look deep into it as I'm on phone, but you are running request 2 times async (with CompletableFuture and spigot api for async) which is redundant

#

Also if your server is lagging it might be worth to send spark report or smth, someone will look into it

bright rock
#

okay now i can't actually tell if the server lagging is because of my plugin or just me not allocating enough memory into it LOL

#

(could also be because i was loading in a bunch of chunks at once)

#

but if Goksi (when available to) or someone else can take a look at my code and make sure there are actually no memory leaks