Skip to content

Commit

Permalink
Merge pull request #175 from grafana/cleanup
Browse files Browse the repository at this point in the history
fix: Minor QoL clean up
  • Loading branch information
bryanhuhta authored Dec 18, 2024
2 parents 1cc00a1 + 32f2f77 commit d7469e9
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.idea/
/.vscode/

# Ignore Gradle project-specific cache directory
.gradle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.pyroscope.javaagent.impl;

import io.pyroscope.http.Format;
import io.pyroscope.javaagent.EventType;
import io.pyroscope.javaagent.Snapshot;
import io.pyroscope.javaagent.api.Exporter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public Ref(T val, Long id) {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Ref<T> valueRef = (Ref<T>) o;

Ref<?> valueRef = (Ref<?>) o;
return id.equals(valueRef.id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@

import one.profiler.AsyncProfiler;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class PyroscopeAsyncProfiler {
static final String libraryPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void stressTest() throws InterruptedException {
}
e.shutdown();
e.awaitTermination(100, TimeUnit.SECONDS);
Snapshot res = Pyroscope.LabelsWrapper.dump();
Pyroscope.LabelsWrapper.dump();
assertEquals(0, ScopedContext.context.get().id);
assertEquals(0, RefCounted.strings.valueToRef.size());
assertEquals(0, RefCounted.contexts.valueToRef.size());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.pyroscope.labels;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class RefTest {
@Test
void testCreateRef() {
Ref<String> ref = new Ref<>("test", 1L);
assertEquals("test", ref.val);
assertEquals(1L, ref.id);
assertEquals(1L, ref.refCount.get());
}

@Test
@SuppressWarnings("unlikely-arg-type")
void testEquals() {
Ref<String> ref1 = new Ref<>("test", 1L);
assertTrue(ref1.equals(ref1));
assertFalse(ref1.equals(null));
assertFalse(ref1.equals(new Integer(3)));
assertTrue(ref1.equals(new Ref<Integer>(3, 1L))); // We don't compare the value types.
}

@Test
void testHashCode() {
Ref<String> ref1 = new Ref<>("test", 1L);
assertEquals(1, ref1.hashCode());
}
}
2 changes: 0 additions & 2 deletions demo/src/main/java/Fib.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

Expand Down

0 comments on commit d7469e9

Please sign in to comment.