maheshwarirohit87 / typica

Automatically exported from code.google.com/p/typica
Apache License 2.0
0 stars 0 forks source link

java.lang.ArrayStoreException #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Exception in thread "Thread-1" java.lang.ArrayStoreException
    at java.lang.System.arraycopy(Native Method)
    at java.util.Arrays.copyOf(Arrays.java:2763)
    at java.util.ArrayList.toArray(ArrayList.java:305)
    at
com.xerox.amazonws.sqs2.QueueService.listMessageQueues(QueueService.java:179)
    at com.xerox.amazonws.sqs2.SQSUtils.getMessageQueue(SQSUtils.java:104)
    at com.xerox.amazonws.sqs2.SQSUtils.connectToQueue(SQSUtils.java:63)
    at com.xerox.amazonws.sqs2.SQSUtils.connectToQueue(SQSUtils.java:44)
    at offline.WorkerThread.run(MapPlayedWorkerThread.java:22)
    at java.lang.Thread.run(Thread.java:619)

Code that generate this error:

        MessageQueue msgQueue;
        try {
            msgQueue = SQSUtils.connectToQueue(Constants.AWS_MAPPLAYEDQUE,
Constants.AWS_ACCESSKEY, Constants.AWS_SECRETACCESSKEY);
        } catch(SQSException notGood) {
            log.severe("Failed to connect to the que " +
Constants.AWS_MAPPLAYEDQUE + " for processing: " + notGood);
            return;
        }

Original issue reported on code.google.com by magnus.a...@gmail.com on 9 Apr 2009 at 8:46

GoogleCodeExporter commented 9 years ago
I've been thinking about how this error could occur. I'm not certain how to 
reproduce, but I'm going to add a 
check for an empty list (where I already check for the list being null). 
Perhaps doing a toArray call on an empty 
list is a problem.

Original comment by dkavan...@gmail.com on 10 Apr 2009 at 1:58

GoogleCodeExporter commented 9 years ago

Original comment by dkavan...@gmail.com on 10 Apr 2009 at 1:59

GoogleCodeExporter commented 9 years ago
ArrayStoreException docs say "Thrown to indicate that an attempt has been made 
to store the wrong type of 
object into an array of objects".  In this case, the source list comes from the 
jaxb generated code which is (by 
contract) supposed to return a List<String>.  I call toArray(new String [] {}). 
By passing an empty array of the 
correct type I want returned, I'm telling the toArray code the proper data 
type, so it has to match the url list 
passed in. Not sure where it could go wrong.

Do you have any details about how to reproduce this? Is 
Constants.AWS_MAPPLAYEDQUE a queue that already 
exists in your SQS account? 

Original comment by dkavan...@gmail.com on 10 Apr 2009 at 2:08

GoogleCodeExporter commented 9 years ago
This seems to happen at random (around every 500-600th attempt to connect).

The que already exists in my account. 

Original comment by magnus.a...@gmail.com on 16 Apr 2009 at 8:11

GoogleCodeExporter commented 9 years ago
I'm looking at this again. I suppose I'll try creating the queue over and over 
till it fails. (or till I tire of running the 
test code). I would suggest re-using the MessageQueue object however. It does 
not maintain state. I routinely 
create a MessageQueue and simply call methods on it over and over (and over and 
over).

Original comment by dkavan...@gmail.com on 13 Oct 2009 at 11:10

GoogleCodeExporter commented 9 years ago
I've been running a loop that simply calls SQSUtils.connectToQueue(...) prints 
the queue URL, then does it again. 
Been running a couple of hours so far.
To be perfectly honest, some of the code in SQSUtils was there to match 
functionality in the Amazon SOAP client 
code. I wanted to make sure it was easy to migrate from the (thread un-safe) 
amazon client to typica.
I think that method of connecting to the queue is heavy weight. What I use is 
the code I added to the SQSutils. 
There are methods like getQueueOrElse(..) and sendMessageForSure(..) that are 
light weight and do exactly what 
they say. they keep trying the call until it works. That gets around the 
occasional 5xx error.

Original comment by dkavan...@gmail.com on 14 Oct 2009 at 1:39

GoogleCodeExporter commented 9 years ago
I'm closing this. I've marked SQSutils.getMessageQueue() deprecated. See issue 
#80 for 
explanation.

Original comment by dkavan...@gmail.com on 23 Mar 2010 at 11:03