Skip to content

Commit 9ec9a5c

Browse files
authored
fix: spotless (#1021)
1 parent c59f373 commit 9ec9a5c

15 files changed

Lines changed: 168 additions & 150 deletions

File tree

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,3 @@ gradle.projectsEvaluated {
156156
}
157157
}
158158
}
159-

scripts/.mvn/wrapper/MavenWrapperDownloader.java

Lines changed: 85 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -13,105 +13,106 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import java.net.*;
1716
import java.io.*;
17+
import java.net.*;
1818
import java.nio.channels.*;
1919
import java.util.Properties;
2020

2121
public class MavenWrapperDownloader {
2222

23-
private static final String WRAPPER_VERSION = "0.5.6";
24-
/**
25-
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26-
*/
27-
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28-
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29-
30-
/**
31-
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32-
* use instead of the default one.
33-
*/
34-
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35-
".mvn/wrapper/maven-wrapper.properties";
23+
private static final String WRAPPER_VERSION = "0.5.6";
24+
/** Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. */
25+
private static final String DEFAULT_DOWNLOAD_URL =
26+
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
27+
+ WRAPPER_VERSION
28+
+ "/maven-wrapper-"
29+
+ WRAPPER_VERSION
30+
+ ".jar";
3631

37-
/**
38-
* Path where the maven-wrapper.jar will be saved to.
39-
*/
40-
private static final String MAVEN_WRAPPER_JAR_PATH =
41-
".mvn/wrapper/maven-wrapper.jar";
32+
/**
33+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use
34+
* instead of the default one.
35+
*/
36+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
37+
".mvn/wrapper/maven-wrapper.properties";
4238

43-
/**
44-
* Name of the property which should be used to override the default download url for the wrapper.
45-
*/
46-
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
39+
/** Path where the maven-wrapper.jar will be saved to. */
40+
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
4741

48-
public static void main(String args[]) {
49-
System.out.println("- Downloader started");
50-
File baseDirectory = new File(args[0]);
51-
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
42+
/**
43+
* Name of the property which should be used to override the default download url for the wrapper.
44+
*/
45+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
5246

53-
// If the maven-wrapper.properties exists, read it and check if it contains a custom
54-
// wrapperUrl parameter.
55-
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56-
String url = DEFAULT_DOWNLOAD_URL;
57-
if(mavenWrapperPropertyFile.exists()) {
58-
FileInputStream mavenWrapperPropertyFileInputStream = null;
59-
try {
60-
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61-
Properties mavenWrapperProperties = new Properties();
62-
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63-
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64-
} catch (IOException e) {
65-
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66-
} finally {
67-
try {
68-
if(mavenWrapperPropertyFileInputStream != null) {
69-
mavenWrapperPropertyFileInputStream.close();
70-
}
71-
} catch (IOException e) {
72-
// Ignore ...
73-
}
74-
}
75-
}
76-
System.out.println("- Downloading from: " + url);
47+
public static void main(String args[]) {
48+
System.out.println("- Downloader started");
49+
File baseDirectory = new File(args[0]);
50+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
7751

78-
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79-
if(!outputFile.getParentFile().exists()) {
80-
if(!outputFile.getParentFile().mkdirs()) {
81-
System.out.println(
82-
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83-
}
84-
}
85-
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
52+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
53+
// wrapperUrl parameter.
54+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
55+
String url = DEFAULT_DOWNLOAD_URL;
56+
if (mavenWrapperPropertyFile.exists()) {
57+
FileInputStream mavenWrapperPropertyFileInputStream = null;
58+
try {
59+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
60+
Properties mavenWrapperProperties = new Properties();
61+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
62+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
63+
} catch (IOException e) {
64+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
65+
} finally {
8666
try {
87-
downloadFileFromURL(url, outputFile);
88-
System.out.println("Done");
89-
System.exit(0);
90-
} catch (Throwable e) {
91-
System.out.println("- Error downloading");
92-
e.printStackTrace();
93-
System.exit(1);
67+
if (mavenWrapperPropertyFileInputStream != null) {
68+
mavenWrapperPropertyFileInputStream.close();
69+
}
70+
} catch (IOException e) {
71+
// Ignore ...
9472
}
73+
}
9574
}
75+
System.out.println("- Downloading from: " + url);
9676

97-
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98-
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99-
String username = System.getenv("MVNW_USERNAME");
100-
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101-
Authenticator.setDefault(new Authenticator() {
102-
@Override
103-
protected PasswordAuthentication getPasswordAuthentication() {
104-
return new PasswordAuthentication(username, password);
105-
}
106-
});
107-
}
108-
URL website = new URL(urlString);
109-
ReadableByteChannel rbc;
110-
rbc = Channels.newChannel(website.openStream());
111-
FileOutputStream fos = new FileOutputStream(destination);
112-
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113-
fos.close();
114-
rbc.close();
77+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
78+
if (!outputFile.getParentFile().exists()) {
79+
if (!outputFile.getParentFile().mkdirs()) {
80+
System.out.println(
81+
"- ERROR creating output directory '"
82+
+ outputFile.getParentFile().getAbsolutePath()
83+
+ "'");
84+
}
85+
}
86+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
87+
try {
88+
downloadFileFromURL(url, outputFile);
89+
System.out.println("Done");
90+
System.exit(0);
91+
} catch (Throwable e) {
92+
System.out.println("- Error downloading");
93+
e.printStackTrace();
94+
System.exit(1);
11595
}
96+
}
11697

98+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
99+
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
100+
String username = System.getenv("MVNW_USERNAME");
101+
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
102+
Authenticator.setDefault(
103+
new Authenticator() {
104+
@Override
105+
protected PasswordAuthentication getPasswordAuthentication() {
106+
return new PasswordAuthentication(username, password);
107+
}
108+
});
109+
}
110+
URL website = new URL(urlString);
111+
ReadableByteChannel rbc;
112+
rbc = Channels.newChannel(website.openStream());
113+
FileOutputStream fos = new FileOutputStream(destination);
114+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
115+
fos.close();
116+
rbc.close();
117+
}
117118
}

scripts/release.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ File(path)
6060
val path = folder.path
6161
val module = folder.name
6262

63-
val file:String
64-
val repositoryUrl:String
63+
val file: String
64+
val repositoryUrl: String
6565

6666
val androidFile = folder.listFiles { it -> it.name.contains("release") && it.extension == "aar" }.firstOrNull()
6767
if (androidFile != null) {

sentry-samples/sentry-samples-android/src/main/java/io/sentry/sample/MainActivity.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@ protected void onCreate(Bundle savedInstanceState) {
2424

2525
binding.sendMessage.setOnClickListener(view -> Sentry.captureMessage("Some message."));
2626

27-
binding.sendUserFeedback.setOnClickListener(view -> {
28-
SentryId sentryId = Sentry.captureException(new Exception("I have feedback"));
29-
30-
UserFeedback userFeedback = new UserFeedback(sentryId);
31-
userFeedback.setComments("It broke on Android. I don't know why, but this happens.");
32-
userFeedback.setEmail("john@me.com");
33-
userFeedback.setName("John Me");
34-
Sentry.captureUserFeedback(userFeedback);
35-
});
27+
binding.sendUserFeedback.setOnClickListener(
28+
view -> {
29+
SentryId sentryId = Sentry.captureException(new Exception("I have feedback"));
30+
31+
UserFeedback userFeedback = new UserFeedback(sentryId);
32+
userFeedback.setComments("It broke on Android. I don't know why, but this happens.");
33+
userFeedback.setEmail("john@me.com");
34+
userFeedback.setName("John Me");
35+
Sentry.captureUserFeedback(userFeedback);
36+
});
3637

3738
binding.captureException.setOnClickListener(
3839
view ->

sentry/src/main/java/io/sentry/Hub.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,27 @@ public SentryId captureEnvelope(
192192
public void captureUserFeedback(UserFeedback userFeedback) {
193193
if (!isEnabled()) {
194194
options
195-
.getLogger()
196-
.log(
197-
SentryLevel.WARNING, "Instance is disabled and this 'captureUserFeedback' call is a no-op.");
195+
.getLogger()
196+
.log(
197+
SentryLevel.WARNING,
198+
"Instance is disabled and this 'captureUserFeedback' call is a no-op.");
198199
} else {
199200
try {
200201
final StackItem item = stack.peek();
201202
if (item != null) {
202203
item.client.captureUserFeedback(userFeedback);
203204
} else {
204-
options.getLogger().log(SentryLevel.FATAL, "Stack peek was null when captureUserFeedback");
205+
options
206+
.getLogger()
207+
.log(SentryLevel.FATAL, "Stack peek was null when captureUserFeedback");
205208
}
206209
} catch (Exception e) {
207-
options.getLogger().log(SentryLevel.ERROR,
208-
"Error while capturing captureUserFeedback: " + userFeedback.toString(), e);
210+
options
211+
.getLogger()
212+
.log(
213+
SentryLevel.ERROR,
214+
"Error while capturing captureUserFeedback: " + userFeedback.toString(),
215+
e);
209216
}
210217
}
211218
}
@@ -476,9 +483,7 @@ public void pushScope() {
476483
if (!isEnabled()) {
477484
options
478485
.getLogger()
479-
.log(
480-
SentryLevel.WARNING,
481-
"Instance is disabled and this 'pushScope' call is a no-op.");
486+
.log(SentryLevel.WARNING, "Instance is disabled and this 'pushScope' call is a no-op.");
482487
} else {
483488
final StackItem item = stack.peek();
484489
if (item != null) {
@@ -545,7 +550,9 @@ public void configureScope(final @NotNull ScopeCallback callback) {
545550
if (!isEnabled()) {
546551
options
547552
.getLogger()
548-
.log(SentryLevel.WARNING, "Instance is disabled and this 'configureScope' call is a no-op.");
553+
.log(
554+
SentryLevel.WARNING,
555+
"Instance is disabled and this 'configureScope' call is a no-op.");
549556
} else {
550557
final StackItem item = stack.peek();
551558
if (item != null) {

sentry/src/main/java/io/sentry/NoOpHub.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public SentryId captureException(Throwable throwable, @Nullable Object hint) {
4141
}
4242

4343
@Override
44-
public void captureUserFeedback(UserFeedback userFeedback) { }
44+
public void captureUserFeedback(UserFeedback userFeedback) {}
4545

4646
@Override
4747
public void startSession() {}

sentry/src/main/java/io/sentry/NoOpSentryClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void close() {}
3030
public void flush(long timeoutMillis) {}
3131

3232
@Override
33-
public void captureUserFeedback(UserFeedback userFeedback) { }
33+
public void captureUserFeedback(UserFeedback userFeedback) {}
3434

3535
@Override
3636
public void captureSession(Session session, @Nullable Object hint) {}

sentry/src/main/java/io/sentry/NoOpSerializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void serialize(SentryEvent event, Writer writer) {}
4444
public void serialize(Session session, Writer writer) throws IOException {}
4545

4646
@Override
47-
public void serialize(UserFeedback userFeedback, Writer writer) throws IOException { }
47+
public void serialize(UserFeedback userFeedback, Writer writer) throws IOException {}
4848

4949
@Override
5050
public void serialize(SentryEnvelope envelope, Writer outputStream) throws Exception {}

sentry/src/main/java/io/sentry/SentryClient.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,24 +191,33 @@ public void captureUserFeedback(UserFeedback userFeedback) {
191191
options.getLogger().log(SentryLevel.WARNING, "Capturing userFeedback without a Sentry Id.");
192192
return;
193193
}
194-
options.getLogger().log(SentryLevel.DEBUG, "Capturing userFeedback: %s", userFeedback.getEventId());
194+
options
195+
.getLogger()
196+
.log(SentryLevel.DEBUG, "Capturing userFeedback: %s", userFeedback.getEventId());
195197

196198
try {
197199
final SentryEnvelope envelope = buildEnvelope(userFeedback);
198200
connection.send(envelope);
199201
} catch (IOException e) {
200-
options.getLogger().log(SentryLevel.WARNING, e, "Capturing user feedback %s failed.", userFeedback.getEventId());
202+
options
203+
.getLogger()
204+
.log(
205+
SentryLevel.WARNING,
206+
e,
207+
"Capturing user feedback %s failed.",
208+
userFeedback.getEventId());
201209
}
202210
}
203211

204212
private SentryEnvelope buildEnvelope(@NotNull UserFeedback userFeedback) {
205213
final List<SentryEnvelopeItem> envelopeItems = new ArrayList<>();
206214

207-
final SentryEnvelopeItem userFeedbackItem = SentryEnvelopeItem.fromUserFeedback(options.getSerializer(), userFeedback);
215+
final SentryEnvelopeItem userFeedbackItem =
216+
SentryEnvelopeItem.fromUserFeedback(options.getSerializer(), userFeedback);
208217
envelopeItems.add(userFeedbackItem);
209218

210219
final SentryEnvelopeHeader envelopeHeader =
211-
new SentryEnvelopeHeader(userFeedback.getEventId(), options.getSdkVersion());
220+
new SentryEnvelopeHeader(userFeedback.getEventId(), options.getSdkVersion());
212221

213222
return new SentryEnvelope(envelopeHeader, envelopeItems);
214223
}

sentry/src/main/java/io/sentry/SentryEnvelopeItem.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,26 @@ public final class SentryEnvelopeItem {
109109
}
110110

111111
public static SentryEnvelopeItem fromUserFeedback(
112-
final @NotNull ISerializer serializer, final @NotNull UserFeedback userFeedback) {
112+
final @NotNull ISerializer serializer, final @NotNull UserFeedback userFeedback) {
113113
Objects.requireNonNull(serializer, "ISerializer is required.");
114114
Objects.requireNonNull(userFeedback, "UserFeedback is required.");
115115

116116
final CachedItem cachedItem =
117-
new CachedItem(
118-
() -> {
119-
try (final ByteArrayOutputStream stream = new ByteArrayOutputStream();
120-
final Writer writer = new BufferedWriter(new OutputStreamWriter(stream, UTF_8))) {
121-
serializer.serialize(userFeedback, writer);
122-
return stream.toByteArray();
123-
}
124-
});
117+
new CachedItem(
118+
() -> {
119+
try (final ByteArrayOutputStream stream = new ByteArrayOutputStream();
120+
final Writer writer = new BufferedWriter(new OutputStreamWriter(stream, UTF_8))) {
121+
serializer.serialize(userFeedback, writer);
122+
return stream.toByteArray();
123+
}
124+
});
125125

126126
SentryEnvelopeItemHeader itemHeader =
127-
new SentryEnvelopeItemHeader(
128-
SentryItemType.UserFeedback, () -> cachedItem.getBytes().length, "application/json", null);
127+
new SentryEnvelopeItemHeader(
128+
SentryItemType.UserFeedback,
129+
() -> cachedItem.getBytes().length,
130+
"application/json",
131+
null);
129132

130133
return new SentryEnvelopeItem(itemHeader, cachedItem::getBytes);
131134
}

0 commit comments

Comments
 (0)