Skip to content
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

Java - Unable to parse XML (Unparsable date) #273

Closed
shaunidiot opened this issue May 19, 2015 · 12 comments
Closed

Java - Unable to parse XML (Unparsable date) #273

shaunidiot opened this issue May 19, 2015 · 12 comments

Comments

@shaunidiot
Copy link

I have 2 Android applications using Steam Condenser for Java. Recently, both of them have failed to work due to the same problem. Unparsable date.

An example of the error log.

com.github.koraktor.steamcondenser.exceptions.SteamCondenserException: XML data could not be parsed.
at com.github.koraktor.steamcondenser.steam.community.SteamId.fetchData(SteamId.java:394)
at com.github.koraktor.steamcondenser.steam.community.SteamId.<init>(SteamId.java:299)
at com.github.koraktor.steamcondenser.steam.community.SteamId.create(SteamId.java:237)
at com.github.koraktor.steamcondenser.steam.community.SteamId.create(SteamId.java:143)
at com.test.removed.$getSteamId.doInBackground(CSGOPreference.java:128)
at com.test.removed$getSteamId.doInBackground(CSGOPreference.java:110)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.text.ParseException: Unparseable date: "November 14null, 2011, 2015" (at offset 11)
at java.text.DateFormat.parse(DateFormat.java:555)
at com.github.koraktor.steamcondenser.steam.community.SteamId.fetchData(SteamId.java:367)
... 11 more

The code I'm using:

SteamId id = SteamId.create("whatevernamehere");
SteamID = Long.toString(id.getSteamId64());

Any idea on how to solve it? Thank you!

@koraktor
Copy link
Owner

Looks like the XML data is broken for those profiles. Do you have examples or does it fail for all profiles?

Dates have always been problematic in the XML data because of various format changes and inconsistencies.

@shaunidiot
Copy link
Author

I did a quick test on an Android app.

new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... voids) {

                    ArrayList<String> names = new ArrayList<String>();
                    // add 6 usernames here. 5 were public profiles. 1 was private.
                    for (String name : names) {
                        try {
                            SteamId id = SteamId.create(name);
                            Log.e("Id64", Long.toString(id.getSteamId64()));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }

                return null;
            }
        }.execute();

Results : Only the first and the last returned the SteamId64. The rest returned the same error.

com.github.koraktor.steamcondenser.exceptions.SteamCondenserException: XML data could not be parsed.
Caused by: java.text.ParseException: Unparseable date: "November 18null, 2012, 2015" (at offset 11)

Took a look in the profile xml files for memberSince tag.
First: December 21st, 2010
Second: May 14th, 2006
Third: June 4th, 2011
Fourth: November 18th, 2012
FIfth: September 10th, 2011
Sixth: Private profile. So the Steam64Id was returned.

The date for all of them is similar, so the one causing the crash on the second to fifth profile was pretty weird. The code seems to be unable to parse the date and causing it to run

this.memberSince = DATE_FORMAT.parse(memberSince + ", " + Calendar.getInstance().get(Calendar.YEAR));

Thanks a lot, and sorry for any English sentence error.

@koraktor
Copy link
Owner

Do you have any profile IDs or custom URLs that I can check?

@shaunidiot
Copy link
Author

Will remove when you've replied me. The above result is used in this order.

removed

@koraktor
Copy link
Owner

Ok, I'll have a look.

@koraktor
Copy link
Owner

Sorry, I'm unable to reproduce this problem.
All of the provided example profiles work for me.

Can you give some information about your environment? Java version and locale in particular.

@shaunidiot
Copy link
Author

I got a feeling it's due to the Java environment I'm working on/targeted for the Android project. I'm using JDK v 1.8.0_31.

@liammcnabb
Copy link

I am having the same problem.
com.github.koraktor.steamcondenser.exceptions.SteamCondenserException: XML data could not be parsed: null at com.github.koraktor.steamcondenser.steam.community.XMLData.<init>(XMLData.java:70) com.github.koraktor.steamcondenser.steam.community.SteamId.fetchData(SteamId.java:330) com.github.koraktor.steamcondenser.steam.community.SteamId.<init>(SteamId.java:299) com.github.koraktor.steamcondenser.steam.community.SteamId.create(SteamId.java:237) com.github.koraktor.steamcondenser.steam.community.SteamId.create(SteamId.java:175)

It happens when you allow the library to fetch the id's data on creation, and seems to be happening regardless of what I put in.

I am also using this with an android application

@koraktor
Copy link
Owner

koraktor commented Jul 4, 2015

Can you provide example profiles?

@liammcnabb
Copy link

I haven't been able to get it to work, so I have been using the profile "demomenz" which I found on the usage section of the website

@koraktor
Copy link
Owner

koraktor commented Jul 6, 2015

@liammcnabb What Java and Steam Condenser version are you using?

This code works flawlessly for me:

SteamId id = SteamId.create("demomenz", true);

The exception you posted hints at some JRE internal problem when parsing the XML. Can you also post the root exception that caused the SteamCondenserException (see #getCause).

@koraktor
Copy link
Owner

koraktor commented Mar 3, 2017

I guess there’s no way to reproduce this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants