nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: googlefonts/glyphsLib
Pull request #834 (2022-11-25 12:50:08)

Allow alternate layers to be unnamed
Fixes the *other* issue with Playfair Italic in #741. Alternate layers may be unnamed because Glyphs does not rely on (or even display) the user-supplied name for them, and we make up our own name for them anyway.

simoncozens: It's not covered. I could come up with a test.

Patch:
diff --git a/Lib/glyphsLib/builder/builders.py b/Lib/glyphsLib/builder/builders.py
index a8a6f84f..6f8207f4 100644
--- a/Lib/glyphsLib/builder/builders.py
+++ b/Lib/glyphsLib/builder/builders.py
@@ -283,7 +283,7 @@ class UFOBuilder(LoggerMixin):
                     )
                 continue
 
-            if not layer.name:
+            if not layer.name and not layer._is_bracket_layer():
                 # Empty layer names are invalid according to the UFO spec.
                 if self.minimize_glyphs_diffs:
                     self.logger.warning(


Test patch:
diff --git a/tests/builder/designspace_gen_test.py b/tests/builder/designspace_gen_test.py
index 8f39e8e1..cadbc472 100644
--- a/tests/builder/designspace_gen_test.py
+++ b/tests/builder/designspace_gen_test.py
@@ -518,6 +518,13 @@ def test_designspace_generation_bracket_other_roundtrip(datadir, ufo_module):
 def test_designspace_generation_multiaxis_bracket(datadir, ufo_module):
     with open(str(datadir.join("Playfair-v.glyphs")), encoding="utf-8") as f:
         font = glyphsLib.load(f)
+
+    # Remove names of bracket layers, make sure the layers get
+    # copied anyway
+    for l in font.glyphs["v"].layers:
+        if l._is_bracket_layer():
+            l.name = ""
+
     designspace = to_designspace(font, ufo_module=ufo_module)
     axes = designspace.axes
     info = font.glyphs["v"].layers[8]._bracket_info(axes)
Repository: googlefonts/glyphsLib
Pull request #916 (2023-06-21 20:49:00)

fix float factors in tokens
should fix the `AttributeError: 'GSLayer' object has no attribute '.5'` part of #914


Patch:
diff --git a/Lib/glyphsLib/builder/tokens.py b/Lib/glyphsLib/builder/tokens.py
index 16faea7d..d9d9b41d 100644
--- a/Lib/glyphsLib/builder/tokens.py
+++ b/Lib/glyphsLib/builder/tokens.py
@@ -74,7 +74,7 @@ class TokenExpander:
         expression = ""
         originaltoken = token
         while len(token) > 0:
-            if token[0] in "0123456789+-*/() ":
+            if token[0] in "0123456789.+-*/() ":
                 expression += token[0]
                 token = token[1:]
                 continue


Test patch:
diff --git a/tests/tokens_test.py b/tests/tokens_test.py
index 4f9815f5..e9c81b2d 100644
--- a/tests/tokens_test.py
+++ b/tests/tokens_test.py
@@ -36,6 +36,7 @@ expander = TokenExpander(TESTFONT, master)
         (r"pos a ${padding * 2} b;", "pos a 500 b;", False),
         (r"pos a ${padding + padding} b;", "pos a 500 b;", False),
         (r"pos a ${padding + (padding/2)} b;", "pos a 375 b;", False),
+        (r"pos a ${padding + (padding/2.5)} b;", "pos a 350 b;", False),
         ("pos a $xxx b;", "", True),
         (r"pos A ${A.sc:width};", "pos A 600;", False),
         (r"pos A ${A:width+1};", "pos A 601;", False),
@@ -50,6 +51,7 @@ expander = TokenExpander(TESTFONT, master)
         # (r"pos A ${A:LSB}", "pos A 600;", False),
         (r"pos A ${A:anchors.top.x};", "pos A 300;", False),
         (r"pos A ${A:anchors.ogonek.y};", "pos A 10;", False),
+        (r"pos A ${A:anchors.ogonek.y*1.5};", "pos A 15;", False),
         (
             r"pos A <${A:anchors.top.x} ${A:anchors.top.y} 0 0>;",
             "pos A <300 700 0 0>;",
Repository: Unleash/unleash-client-java
Pull request #45 (2017-11-16 02:15:09)

Implement hashing with murmur
This is @ivarconr's PR with some tests added to match the node client.

If these look good then I'll work on the go client next.

Node client PR https://github.com/Unleash/unleash-client-node/pull/54


Patch:
diff --git a/pom.xml b/pom.xml
index 37779562..b50576fd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,6 +51,12 @@
             <version>${version.log4j2}</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.sangupta</groupId>
+            <artifactId>murmur</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        
         <!-- Test dependencies -->
         <dependency>
             <groupId>junit</groupId>
diff --git a/src/main/java/no/finn/unleash/strategy/StrategyUtils.java b/src/main/java/no/finn/unleash/strategy/StrategyUtils.java
index 1f3714c9..4037f356 100644
--- a/src/main/java/no/finn/unleash/strategy/StrategyUtils.java
+++ b/src/main/java/no/finn/unleash/strategy/StrategyUtils.java
@@ -1,5 +1,7 @@
 package no.finn.unleash.strategy;
 
+import com.sangupta.murmur.Murmur3;
+
 public final class StrategyUtils {
     private static final int ONE_HUNDRED = 100;
 
@@ -25,15 +27,20 @@ public final class StrategyUtils {
     }
 
     /**
-     * Takes to string inputs concat them, produce a hashCode and return a normalized value between 0 and 100;
+     * Takes to string inputs concat them, produce a hash and return a normalized value between 0 and 100;
      *
      * @param identifier
      * @param groupId
      * @return
      */
     public static int getNormalizedNumber(String identifier, String groupId) {
-        int hashCode = Math.abs((groupId + ':' + identifier).hashCode());
-        return hashCode % ONE_HUNDRED + 1;
+        return getNormalizedNumber(identifier, groupId, ONE_HUNDRED);
+    }
+
+    public static int getNormalizedNumber(String identifier, String groupId, int normalizer) {
+        byte[] value = (groupId + ':' + identifier).getBytes();
+        long hash = Murmur3.hash_x86_32(value, value.length, 0);
+        return (int)(hash % normalizer) + 1;
     }
 
     /**


Test patch:
diff --git a/src/test/java/no/finn/unleash/strategy/StrategyUtilsTest.java b/src/test/java/no/finn/unleash/strategy/StrategyUtilsTest.java
new file mode 100644
index 00000000..1a38a6a8
--- /dev/null
+++ b/src/test/java/no/finn/unleash/strategy/StrategyUtilsTest.java
@@ -0,0 +1,15 @@
+package no.finn.unleash.strategy;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class StrategyUtilsTest {
+
+    @Test
+    public void normalized_values_are_the_same_across_node_java_and_go_clients() {
+        assertEquals(73, StrategyUtils.getNormalizedNumber("123", "gr1"));
+        assertEquals(25, StrategyUtils.getNormalizedNumber("999", "groupX"));
+    }
+
+}
\ No newline at end of file
Repository: Unleash/unleash-client-java
Pull request #151 (2022-01-31 13:14:40)

fix: make bootstrap not fail when passed invalid json
Co-authored-by: Simon Hornby <simon@getunleash.ai>


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 225992e0..10e1dd2c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
 # Changelog
 
-
+## 5.0.4
+- fix: Bootstrap no longer fails hard when passed invalid json. It now returns an empty list of features if the bootstrap json could not be parsed.
 ## 5.0.0
 - chore: Refactor package names. Moving from `no.finn.unleash` to `io.getunleash` to reflect where development is taking place.
 
diff --git a/src/main/java/io/getunleash/repository/ToggleBootstrapHandler.java b/src/main/java/io/getunleash/repository/ToggleBootstrapHandler.java
index 57738d6b..19ed2f8c 100644
--- a/src/main/java/io/getunleash/repository/ToggleBootstrapHandler.java
+++ b/src/main/java/io/getunleash/repository/ToggleBootstrapHandler.java
@@ -1,5 +1,6 @@
 package io.getunleash.repository;
 
+import com.google.gson.JsonSyntaxException;
 import io.getunleash.UnleashException;
 import io.getunleash.event.EventDispatcher;
 import io.getunleash.event.UnleashEvent;
@@ -28,7 +29,7 @@ public class ToggleBootstrapHandler {
                 ToggleCollection toggleCollection = JsonToggleParser.fromJson(stringReader);
                 eventDispatcher.dispatch(new ToggleBootstrapRead(toggleCollection));
                 return toggleCollection;
-            } catch (IllegalStateException ise) {
+            } catch (IllegalStateException | JsonSyntaxException ise) {
                 eventDispatcher.dispatch(
                         new UnleashException("Failed to read toggle bootstrap", ise));
             }


Test patch:
diff --git a/src/test/java/io/getunleash/repository/ToggleBootstrapHandlerTest.java b/src/test/java/io/getunleash/repository/ToggleBootstrapHandlerTest.java
index 5af03c04..b575366e 100644
--- a/src/test/java/io/getunleash/repository/ToggleBootstrapHandlerTest.java
+++ b/src/test/java/io/getunleash/repository/ToggleBootstrapHandlerTest.java
@@ -42,6 +42,18 @@ public class ToggleBootstrapHandlerTest {
         assertThat(parse.getFeatures()).isEmpty();
     }
 
+    @Test
+    public void returns_empty_collection_if_invalid_json_string() {
+        UnleashConfig config =
+            UnleashConfig.builder()
+                .appName("test")
+                .unleashAPI("http://http://unleash.org")
+                .build();
+        ToggleBootstrapHandler handler = new ToggleBootstrapHandler(config);
+        ToggleCollection parse = handler.parse("qw;lkeruiqwplkerjql;kjglksjdfglksdjflkwsdj");
+        assertThat(parse.getFeatures()).isEmpty();
+    }
+
     @Test
     public void handles_provider_returning_null() {
         UnleashConfig config =
Repository: Unleash/unleash-client-java
Pull request #243 (2024-05-08 11:25:20)

fix: enableAll and disableAll overrides fallback
As discussed in #239 - When all is enabled, we had a bit of a surprising
behaviour where we'd fallback to fallback action for
`isEnabled(featureName, fallback)` even if all was enabled and feature
did not exist.

This PR fixes that, and adds tests to confirm this behaviour is intentional.

closes: #239


Patch:
diff --git a/src/main/java/io/getunleash/FakeUnleash.java b/src/main/java/io/getunleash/FakeUnleash.java
index 11b5bf42..0e88d135 100644
--- a/src/main/java/io/getunleash/FakeUnleash.java
+++ b/src/main/java/io/getunleash/FakeUnleash.java
@@ -38,7 +38,8 @@ public class FakeUnleash implements Unleash {
     @Override
     public boolean isEnabled(
             String toggleName, BiPredicate<String, UnleashContext> fallbackAction) {
-        if (!features.containsKey(toggleName)) {
+        if ((!enableAll && !disableAll || excludedFeatures.containsKey(toggleName))
+                && !features.containsKey(toggleName)) {
             return fallbackAction.test(toggleName, UnleashContext.builder().build());
         }
         return isEnabled(toggleName);


Test patch:
diff --git a/src/test/java/io/getunleash/FakeUnleashTest.java b/src/test/java/io/getunleash/FakeUnleashTest.java
index a4c00977..daaaf09c 100644
--- a/src/test/java/io/getunleash/FakeUnleashTest.java
+++ b/src/test/java/io/getunleash/FakeUnleashTest.java
@@ -179,4 +179,32 @@ public class FakeUnleashTest {
         FakeUnleash fakeUnleash = new FakeUnleash();
         fakeUnleash.more().countVariant("toggleName", "variantName");
     }
+
+    @Test
+    public void
+            if_all_is_enabled_should_return_true_even_if_feature_does_not_exist_and_fallback_returns_false() {
+        FakeUnleash fakeUnleash = new FakeUnleash();
+        fakeUnleash.enableAll();
+        assertThat(fakeUnleash.isEnabled("my.non.existing.feature", (name, context) -> false))
+                .isTrue();
+    }
+
+    @Test
+    public void
+            if_all_is_disabled_should_return_false_even_if_feature_does_not_exist_and_fallback_returns_true() {
+        FakeUnleash fakeUnleash = new FakeUnleash();
+        fakeUnleash.disableAll();
+        assertThat(fakeUnleash.isEnabled("my.non.existing.feature", (name, context) -> true))
+                .isFalse();
+    }
+
+    @Test
+    public void all_enabled_and_exclusion_toggle_returns_expected_result() {
+        FakeUnleash fakeUnleash = new FakeUnleash();
+        fakeUnleash.enableAllExcept("my.feature.that.should.be.disabled");
+        assertThat(
+                        fakeUnleash.isEnabled(
+                                "my.feature.that.should.be.disabled", (name, context) -> false))
+                .isFalse();
+    }
 }
Repository: Unleash/unleash-client-java
Pull request #264 (2025-01-21 14:42:19)

fix: revert previous version scheme
<!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes

After some digging I realized that same version setting we use for the new `x-unleash-sdk` is also used for the registration calls. I'm reverting back the `unleash-client-java:version` convention instead of the new `unleash-java@version`. We use the colon convention a lot in the backend code. Since the new header is not used yet it can be synced with the old convention for now.

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important?  -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? -->



Patch:
diff --git a/src/main/java/io/getunleash/util/UnleashConfig.java b/src/main/java/io/getunleash/util/UnleashConfig.java
index 485fdb8e..24443a39 100644
--- a/src/main/java/io/getunleash/util/UnleashConfig.java
+++ b/src/main/java/io/getunleash/util/UnleashConfig.java
@@ -736,7 +736,7 @@ public class UnleashConfig {
             String version =
                     Optional.ofNullable(getClass().getPackage().getImplementationVersion())
                             .orElse("development");
-            return "unleash-java@" + version;
+            return "unleash-client-java:" + version;
         }
     }
 }


Test patch:
diff --git a/src/test/java/io/getunleash/util/UnleashConfigTest.java b/src/test/java/io/getunleash/util/UnleashConfigTest.java
index 63fe6e2b..dd2054b7 100644
--- a/src/test/java/io/getunleash/util/UnleashConfigTest.java
+++ b/src/test/java/io/getunleash/util/UnleashConfigTest.java
@@ -113,7 +113,7 @@ public class UnleashConfigTest {
         UnleashConfig config =
                 UnleashConfig.builder().appName("my-app").unleashAPI("http://unleash.org").build();
 
-        assertThat(config.getSdkVersion()).isEqualTo("unleash-java@development");
+        assertThat(config.getSdkVersion()).isEqualTo("unleash-client-java:development");
     }
 
     @Test
@@ -160,7 +160,7 @@ public class UnleashConfigTest {
         assertThat(connection.getRequestProperty(UNLEASH_INSTANCE_ID_HEADER)).isEqualTo(instanceId);
         assertThat(connection.getRequestProperty(UNLEASH_CONNECTION_ID_HEADER)).hasSize(36);
         assertThat(connection.getRequestProperty(UNLEASH_SDK_HEADER))
-                .isEqualTo("unleash-java@development");
+                .isEqualTo("unleash-client-java:development");
         assertThat(connection.getRequestProperty("User-Agent")).isEqualTo(appName);
     }
Repository: Unleash/unleash-client-java
Pull request #278 (2025-02-06 10:34:52)

fix: prevent connection overwrite
<!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes

Prevent connection id overwrite with custom headers

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important?  -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? -->


coveralls: 
[![Coverage Status](https://coveralls.io/builds/72109147/badge)](https://coveralls.io/builds/72109147)

coverage: 80.918% (+1.1%) from 79.78%
when pulling **c21e4ac23305d906c14017e4ed5849ff243b2c95 on prevent-connection-overwrite**
into **f32b4e0e282ca8cd72e7d79d6524404509f6701e on main**.


Patch:
diff --git a/src/main/java/io/getunleash/util/UnleashConfig.java b/src/main/java/io/getunleash/util/UnleashConfig.java
index 761dbcb2..83e4d162 100644
--- a/src/main/java/io/getunleash/util/UnleashConfig.java
+++ b/src/main/java/io/getunleash/util/UnleashConfig.java
@@ -176,13 +176,14 @@ public class UnleashConfig {
     public static void setRequestProperties(HttpURLConnection connection, UnleashConfig config) {
         connection.setRequestProperty(UNLEASH_APP_NAME_HEADER, config.getAppName());
         connection.setRequestProperty(UNLEASH_INSTANCE_ID_HEADER, config.getInstanceId());
-        connection.setRequestProperty(UNLEASH_CONNECTION_ID_HEADER, config.getConnectionId());
         connection.setRequestProperty(UNLEASH_SDK_HEADER, config.getSdkVersion());
         connection.setRequestProperty("User-Agent", config.getAppName());
         connection.setRequestProperty(
                 "Unleash-Client-Spec", config.getClientSpecificationVersion());
         config.getCustomHttpHeaders().forEach(connection::setRequestProperty);
         config.customHttpHeadersProvider.getCustomHeaders().forEach(connection::setRequestProperty);
+        // prevent overwrite
+        connection.setRequestProperty(UNLEASH_CONNECTION_ID_HEADER, config.getConnectionId());
     }
 
     private void enableProxyAuthentication() {


Test patch:
diff --git a/src/test/java/io/getunleash/util/UnleashConfigTest.java b/src/test/java/io/getunleash/util/UnleashConfigTest.java
index 30d8b1c0..e0d08e55 100644
--- a/src/test/java/io/getunleash/util/UnleashConfigTest.java
+++ b/src/test/java/io/getunleash/util/UnleashConfigTest.java
@@ -148,6 +148,7 @@ public class UnleashConfigTest {
                         .appName(appName)
                         .instanceId(instanceId)
                         .unleashAPI(unleashAPI)
+                        .customHttpHeader(UNLEASH_CONNECTION_ID_HEADER, "ignore")
                         .build();
 
         URL someUrl = new URL(unleashAPI + "/some/arbitrary/path");
Repository: amzn/ion-java
Pull request #171 (2018-10-25 20:53:03)

WriteBuffer truncation fix
Calls to `WriteBuffer#truncate(long)` modify an internal `index` value that tracks the last block in the buffer that contains data to write. Our current implementation of `WriteBuffer#writeTo(OutputStream)` ignores the `index` value and writes the contents of all allocated blocks to the `OutputStream`.

In cases where multiple blocks have been allocated and `truncate()` should cause one or more to be ignored, this bug results in unparsable data. This problem is relatively rare, but it can happen when writing a very large (>32kb) local symbol table at the head of a stream.

*Description of changes:*
1. `WriteBuffer#writeTo(OutputStream)` has been modified to only write the contents of blocks `[0, index]`.
2. A new unit test has been added.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.



Patch:
diff --git a/src/software/amazon/ion/impl/bin/WriteBuffer.java b/src/software/amazon/ion/impl/bin/WriteBuffer.java
index 34ef9fbc..b5ddb05b 100644
--- a/src/software/amazon/ion/impl/bin/WriteBuffer.java
+++ b/src/software/amazon/ion/impl/bin/WriteBuffer.java
@@ -1071,9 +1071,10 @@ import java.util.List;
     /** Write the entire buffer to output stream. */
     public void writeTo(final OutputStream out) throws IOException
     {
-        for (final Block block : blocks)
+        for (int i = 0; i <= index; i++)
         {
-            out.write(block.data, 0, block.limit);
+	    Block block = blocks.get(i);
+	    out.write(block.data, 0, block.limit);
         }
     }
 


Test patch:
diff --git a/test/software/amazon/ion/impl/bin/WriteBufferTest.java b/test/software/amazon/ion/impl/bin/WriteBufferTest.java
index e5386c92..8c200e9c 100644
--- a/test/software/amazon/ion/impl/bin/WriteBufferTest.java
+++ b/test/software/amazon/ion/impl/bin/WriteBufferTest.java
@@ -915,4 +915,12 @@ public class WriteBufferTest
         buf.writeBytes("DOO".getBytes("UTF-8"));
         assertBuffer("ARGLEFOOBARGLEDOO".getBytes("UTF-8"));
     }
+
+    @Test
+    public void testTruncate() throws IOException
+    {
+        buf.writeBytes("ARGLEFOOBARGLEDOO".getBytes("UTF-8"));
+        buf.truncate(3);
+        assertBuffer("ARG".getBytes("UTF-8"));
+    }
 }
Repository: amzn/ion-java
Pull request #175 (2018-10-31 19:21:42)

Avoids calling WriteBuffer.finish() if the writer is closed
Issue #174 

Modifies IonRawBinaryWriter.flush() so WriteBuffer.finish() is not called when the writer is closed, thus avoiding the exception case introduced by #171.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.



Patch:
diff --git a/src/software/amazon/ion/impl/bin/IonRawBinaryWriter.java b/src/software/amazon/ion/impl/bin/IonRawBinaryWriter.java
index ae3e7bf4..b8e13d68 100644
--- a/src/software/amazon/ion/impl/bin/IonRawBinaryWriter.java
+++ b/src/software/amazon/ion/impl/bin/IonRawBinaryWriter.java
@@ -1432,6 +1432,10 @@ import software.amazon.ion.Timestamp;
 
     public void finish() throws IOException
     {
+        if (closed)
+        {
+            return;
+        }
         if (!containers.isEmpty())
         {
             throw new IllegalStateException("Cannot finish within container: " + containers);
@@ -1478,7 +1482,6 @@ import software.amazon.ion.Timestamp;
         {
             return;
         }
-        closed = true;
         try
         {
             try
@@ -1497,6 +1500,7 @@ import software.amazon.ion.Timestamp;
         }
         finally
         {
+            closed = true;
             if (streamCloseMode == StreamCloseMode.CLOSE)
             {
                 // release the stream


Test patch:
diff --git a/test/software/amazon/ion/impl/bin/IonRawBinaryWriterTest.java b/test/software/amazon/ion/impl/bin/IonRawBinaryWriterTest.java
index 909681de..33745b97 100644
--- a/test/software/amazon/ion/impl/bin/IonRawBinaryWriterTest.java
+++ b/test/software/amazon/ion/impl/bin/IonRawBinaryWriterTest.java
@@ -179,6 +179,15 @@ public class IonRawBinaryWriterTest extends Assert
         new NullDesc(STRUCT,    "null.struct")
     };
 
+    @Test
+    public void testFinishOnClose() throws IOException
+    {
+        // verify data is flushed if a writer is closed prior to calling finish()
+        writer.writeNull();
+        writer.close();
+        assertValue("null.null");
+    }
+
     @Test
     public void testNullNull() throws Exception
     {