-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
While experimenting with the library, I found that on the third getNearbyLocations call the GooglePlaces object hangs the thread. However, if I instead initiate a new GooglePlaces object every 2 calls, the objects work fine.
Here is the code I used to test this. The coordinates were chosen due to the large amount of nearby restaurants. I have found that sameInstanceTest() hangs after 2 print statements, while multipleInstanceTest() outputs 5 print statements and exits.
public void multipleInstanceTest(){
GooglePlaces gpl = new GooglePlaces(API_KEYS[0]);
int usages = 0;
double[][] testDoubles = new double[][]{
new double[]{40.7607077,-73.980695},
new double[]{40.7607077,-73.980695},
new double[]{40.7607077,-73.980695},
new double[]{40.7607077,-73.980695},
new double[]{40.7607077,-73.980695}
};
double range = 6000;
for (double[] coords : testDoubles){
List<Place> places = new ArrayList<>();
try {
places = gpl.getNearbyPlaces(coords[0], coords[1],range, 20, Param.name("type").value("food"));
} catch (Exception e){
//Default to 0
}
usages ++;
System.out.printf("Got %d locations at coords %f,%f\n",places.size(),coords[0],coords[1]);
if (usages == 2){
gpl = new GooglePlaces(API_KEYS[0]);
usages = 0;
}
}
}
public void sameIstanceTest(){
GooglePlaces gpl = new GooglePlaces(API_KEYS[0]);
double[][] testDoubles = new double[][]{
new double[]{40.7607077,-73.980695},
new double[]{40.7607077,-73.980695},
new double[]{40.7607077,-73.980695},
new double[]{40.7607077,-73.980695},
new double[]{40.7607077,-73.980695}
};
double range = 6000;
for (double[] coords : testDoubles){
List<Place> places = new ArrayList<>();
try {
places = gpl.getNearbyPlaces(coords[0], coords[1],range, 20, Param.name("type").value("food"));
} catch (Exception e){
}
System.out.printf("Got %d locations at coords %f,%f\n",places.size(),coords[0],coords[1]);
}
}
Metadata
Metadata
Assignees
Labels
No labels