SFS2X guava library problem (probably classloader prob.)

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

kaandok
Posts: 9
Joined: 11 Aug 2012, 17:59

SFS2X guava library problem (probably classloader prob.)

Postby kaandok » 11 Aug 2012, 18:25

Hi,

I have two jars extensions-shared.jar and extension.jar
extension-shared.jar contains model classes and google guava library jar, this is placed under extensions/__lib__

extension.jar contains the extension code referencing guava library (such as Lists.newArrayList(getParentExtension().getUserList()) )

whenever a line of code referencing the guava library executes, the extension logic becomes stuck (i.e. the extension program stops executing anymore)
no errors, etc. printed to logs.

I can successfully connect to admin interface during the problem, no unusual actiivty is present.
Hovever, most of the cpu time looks like being spent in a thread called DestroyJavaVM ( is this normal :) )?

any thoughts related to cause?

note: when I use ArrayList, etc. (corresponding JVM classes directly) or execute the logic with Guava libraries outside of SFS, there are no problems.
so, it is highly probable that this is not a logic error on my side
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2X guava library problem (probably classloader prob.)

Postby Lapo » 12 Aug 2012, 08:01

That is weird!
The DestroyJavaVM thread should never be busy unless the JVM is shutting down.
http://stackoverflow.com/questions/5766 ... dispatcher

Are you sure you aren't getting any errors whatsoever in the logs?

such as Lists.newArrayList(getParentExtension().getUserList())

Why would you do this? You are already getting a List... why duplicating it?
Lapo
--
gotoAndPlay()
...addicted to flash games
kaandok
Posts: 9
Joined: 11 Aug 2012, 17:59

Re: SFS2X guava library problem (probably classloader prob.)

Postby kaandok » 12 Aug 2012, 08:38

You are right with the DestroyJavaVM thread, as time goes by its time utilization ratio decreases
(so, I'm guessing it's not working and the high utilization is related to the way statistics about threads are gathered)

No errors, at all, I checked every single place that can contain a log :)

According to the method signatures, getParentZone().getUserList() returns Collection<User>,
however, send(...) methods expect List<User>. you can't always assume that a collection is also
a list; if it is the case for these method calls I would be more than happy to use the return value of
getParentZone().getUserList() directly in the send(...) methods :)

Thanks & Regards
kaandok
Posts: 9
Joined: 11 Aug 2012, 17:59

Re: SFS2X guava library problem (probably classloader prob.)

Postby kaandok » 12 Aug 2012, 11:35

By the way, the Guava problem is also solved with the solution from: http://www.smartfoxserver.com/forums/viewtopic.php?f=18&t=14690

My question about whether the collection returned by getParentZone().getUserList() is backed by something that also implements the List interface still stands, though :)

Thanks and Regards
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: SFS2X guava library problem (probably classloader prob.)

Postby rjgtav » 14 Aug 2012, 21:38

Hi.
When you do Zone.getUserList() it returns an ArrayList of users.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2X guava library problem (probably classloader prob.)

Postby Lapo » 15 Aug 2012, 06:59

To expand rjgtav's answer a little more:
the methods returning groups of Users or Rooms use the Collection supertype because at times a List is used and some other times a Set is used instead depending on the case.

We should probably document this better, so that type casting is straightforward. In any case it takes just a few seconds to simply try casting the collection to either List or Set. If no error arises you can be assured that you have a List (or Set) in your hand, and this will never change.
Typecasting will also avoid the creation of another list which can be a little resource-consuming when the returned collection contains thousands of elements.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 113 guests