Good afternoon.
I can not understand why the code does not work after publishing in the Google market.
Before publishing in android studio code
ArrayList<TableAccount> tableAccount = getTableAccount();
String jsonStr = new Gson().toJson(tableAccount);
result:
Log.d(TAG, "RESULT: " + jsonStr);
RESULT: [{"name":"payment","valueFloat":0.0,"valueInt":0,"valueStr":"no"}]
But, after posting, I see:
Log.d(TAG, "RESULT: " + jsonStr);
RESULT: [{"a":"payment","b":"no","c":0,"d":0.0}]
Why do the letters a b c appear?
And where do the keys disappear? ["name", "valueFloat", "valueInt", "valueStr"]
Apparently, you turned on ProGuard/R8 for your release build, and its obfuscation mode renamed your fields.
The biggest lesson from here is to make sure that you test your release builds before uploading them to Google Play.
To fix the problem, you could:
Turn off ProGuard/R8 entirely,
Leave it on but disable obfuscation entirely,
Leave it on but disable obfuscation for these specific classes, or
Use #SerializedName annotations to teach Gson what names to use, instead of its default of using Java reflection to look up the names of the fields (as obfuscation renames those fields)
Related
I write discord bot with using JDA and i have one important question how to download attachments or work with them? Because my IntelliJ say "Deprecated API usage" for method like attachment.downloadToFile("name.png);
So now we shouldn't download users files send in message? Or how we should do it in good way? I search a lot of wiki from JDA and different posts, but everywhere i didn't see, a new option to handle this download files, becasue all methods to download, are "Deprecated API" even method like "attachment.retrieveInputStream().join()" retrieveInputStream its too not good way :(
Search a lot on wiki/others pages for more information but nothing found :(
The deprecation notice says this:
Deprecated.
Replaced by getProxy(), see FileProxy.downloadToFile(File)
This means you should use attachment.getProxy().downloadToFile(File) instead.
Example:
attachment.getProxy().downloadToFile(new File("myimage.png")).thenAccept(file -> {
System.out.println("Written to file " + file.getAbsolutePath() + ".");
});
Or using NIO instead:
attachment.getProxy().downloadToPath().thenAccept(path -> {
System.out.println("Written to file " + path + ". Total size: " + Files.size(path));
});
This Statement is rightfully flagged by Checkmarx as as possible LDAP_Injection.
String filter = "(&(objectclass=accessGroup)(member=cn=*)(dsApplicationName=" + application + "))";
With the ESAPI-Encoder, I would expect that this solves the Problem:
String saneApplication = org.owasp.esapi.reference.DefaultEncoder.getInstance().encodeForLDAP(application);
String filter = "(&(objectclass=accessGroup)(member=cn=*)(dsApplicationName=" + saneApplication + "))";
But Checkmarx still flags it as LDAP_Injection.
No idea how to solve this properly.
Thanks
Thomas
You can override the functions used as a sanitizer in the query, using CxAudit.
E.g. have a project/corporate override for Find_LDAP_Sanitize(), and include (in addition to the original) the ESAPI functions - select the method calls, and add those to the original list.
P.S. already asked for that to be added into the default, but I have no idea when it will be :-)
P.P.S. OWASP ESAPI is pretty much being superseded by the OWASP Encoder project, however that doesn't really support LDAP encoding.
Long term, you may want to restructure your code to avoid any kind of concatenation.
I am writing a Dropbox console application. I need to find last modification for my account. I can get file metadata with date of last modification, like this:
DbxEntry.WithChildren listing = client.getMetadataWithChildren(path);
for (DbxEntry child : listing.children) {
System.out.println(" " + child.name + ": " + child.toString());
}
But how can I find the latest modification for all of my folders?
The Dropbox API and the official Dropbox Java SDK don't expose a modified time for folders, but we'll consider it a feature request.
For files, you can access clientModified and serverModified on FileMetadata.
(Note that the code in your question uses the old, deprecated Java SDK, so you should switch to the new one.)
How can I make an eclipse java template that allows generating java code that eases the repeating part of registering code for a java method. Example:
Assume that the class description is like so:
class A{
public static void methodName(String s, int i, Object o) {
}
}
Now, what I want is to make a template that does something somewhat like this:
"${enclosing_type}.${enclosing_method}(" + ${variable1} + ", " + ${variable2} + ", " + ${variable3} + ")"
Given the available Eclipse variables I know, the idea would probably be:
"${enclosing_type}.${enclosing_method}(" + ${enclosing_method_arguments(" + \", \" + ")} + ")"
Where that argument would signal the glue to the join of each element of the enclosing_method_arguments. The result of the format would be:
"A.methodName(" + s + ", " + i + ", " + o + ")"
If there's an even better alternative, I'm open for suggestions.
This is meant to be used with a piece of code that is executed a LOT,
Unfortunately, String.format() (and related) "solution" is not an option here due to the requirement above and due to other inherited requirements with what I'm working on. It must generate that code in that format no matter what, unfortunately.
I'm open to any plugins that allow that and, if eclipse doesn't have it, I'm open to make a plugin myself... In case of me having to do a plugin please do show me the resources required to make it.
It should be possible to write a custom variable resolver. It is defined by org.eclipse.ui.editors.templates extension point
You could implement a custom resolver that points to Java context (its id is java defined in jdt.ui).
I don't know any plugins that would provide what you need out of the box.
If you are new to Eclipse plug-ins you might need to read the documentation on extending Eclipse. However, the task is really simple, so you should be able to do it after just a glimpse over the docs.
This piece of code moves all current versions of files from one folder to another but leaves all older versions unmoved. (Context is java code of DFC accessing Documentum.)
String strObjId = versionColl.getString("r_object_id");
com.documentum.fc.common.IDfId curObjectID = new DfId(strObjId);
IDfSysObject curObj = (IDfSysObject)sess.getObject(curObjectID);
versionlabel = curObj.getAllRepeatingStrings("r_version_label", ",");
System.out.println("Moving document with Name:" + objName + " and version:" + versionlabel);
if (runMode.equals("1")) {
curObj.unlink(oldpath);
curObj.link(newpath);
curObj.setString("a_special_app", curObj.getString("r_modifier"));
curObj.setTime("a_last_review_date", curObj.getTime("r_modify_date"));
curObj.setString("a_category","MOVED");
curObj.save();
System.out.println("Successfully Moved document with Name:" + objName + " and version:" + versionlabel);
}
The error we were getting while moving older versions was "document immutable". So we added this piece of code that temporarily disables the immutable flag, allows the file to be moved and then resets the immutable flag to true.
curObj.setBoolean("r_immutable_flag", false);
The problem then was that this code ran perfectly on our dev machine (windows) while it crashed on production(windows) (gave link error). Any ideas as to why this is acting as it is and other codes to solve this issue would be great. Thanks.
Based on the little info given, it could be just about anything but my guess is that it's a permissions issue. Specifically, the user running this code does not have the proper permissions to move one(or more) of the documents you are trying to move OR the user running the code does not have enough permissions to link objects to the target folder.