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

[wpiutil] DataLog.addSchema(): Don't add into a set view #5829

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void resume() {
* @return True if schema already registered
*/
public boolean hasSchema(String name) {
return m_schemaSet.contains(name);
return m_schemaMap.containsKey(name);
}

/**
Expand All @@ -134,7 +134,7 @@ public boolean hasSchema(String name) {
* @param timestamp Time stamp (may be 0 to indicate now)
*/
public void addSchema(String name, String type, byte[] schema, long timestamp) {
if (!m_schemaSet.add(name)) {
if (m_schemaMap.putIfAbsent(name, 1) != null) {
return;
}
DataLogJNI.addSchema(m_impl, name, type, schema, timestamp);
Expand Down Expand Up @@ -168,7 +168,7 @@ public void addSchema(String name, String type, byte[] schema) {
* @param timestamp Time stamp (may be 0 to indicate now)
*/
public void addSchema(String name, String type, String schema, long timestamp) {
if (!m_schemaSet.add(name)) {
if (m_schemaMap.putIfAbsent(name, 1) != null) {
return;
}
DataLogJNI.addSchemaString(m_impl, name, type, schema, timestamp);
Expand Down Expand Up @@ -506,5 +506,4 @@ private void addSchemaImpl(Struct<?> struct, long timestamp, Set<String> seen) {

private long m_impl;
private final ConcurrentMap<String, Integer> m_schemaMap = new ConcurrentHashMap<>();
private final Set<String> m_schemaSet = m_schemaMap.keySet();
}